]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-248] накладная товаров замены при передаче смены origin/feature_smirnov_erp-248_shift_transfer_replacement_invoice
authorAlexander Smirnov <fredeom@mail.ru>
Wed, 27 Nov 2024 07:48:38 +0000 (10:48 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Wed, 27 Nov 2024 07:48:38 +0000 (10:48 +0300)
erp24/controllers/ShiftTransferController.php
erp24/migrations/m241126_125723_create_table_shift_transfer_replacement_invoice.php [new file with mode: 0755]
erp24/records/ReplacementInvoice.php [new file with mode: 0644]
erp24/records/ReplacementInvoiceProducts.php [new file with mode: 0644]
erp24/views/shift-transfer/invoice-index.php [new file with mode: 0644]
erp24/views/shift-transfer/invoice-update.php [new file with mode: 0644]
erp24/views/shift-transfer/invoice-view.php [new file with mode: 0644]
erp24/web/js/shift-transfer/invoice-update.js [new file with mode: 0644]

index 176b6c0f7abe558bbae29d4c1ead8df463f62f95..19042f994a9ef5305a21f6bf78f37a15c65345b9 100644 (file)
@@ -13,6 +13,8 @@ use yii_app\records\MultipleModel;
 use yii_app\records\Prices;
 use yii_app\records\Products1c;
 use yii_app\records\ProductsClass;
+use yii_app\records\ReplacementInvoice;
+use yii_app\records\ReplacementInvoiceProducts;
 use yii_app\records\SelfCostProduct;
 use yii_app\records\ShiftRemains;
 use yii_app\records\ShiftTransfer;
@@ -140,4 +142,90 @@ class ShiftTransferController extends Controller
 
         return $this->redirect(['/shift-transfer']);
     }
+
+    public function actionInvoiceIndex() {
+        $replacementInvoices = ReplacementInvoice::find()->all();
+
+        $storeNameById = TaskService::getEntitiesByAlias('store');
+
+        $admins = ArrayHelper::map(Admin::find()->all(), 'id', 'name');
+
+        return $this->render('invoice-index',
+            compact('replacementInvoices', 'storeNameById', 'admins'));
+    }
+
+    public function actionInvoiceCreate() {
+        $replacementInvoice = new ReplacementInvoice;
+
+        $isCreate = true;
+
+        $storeNameById = TaskService::getEntitiesByAlias('store');
+
+        return $this->render('invoice-update', compact('replacementInvoice', 'isCreate',
+            'storeNameById'));
+    }
+
+    public function actionInvoiceUpdate($id = null) {
+        $replacementInvoice = ReplacementInvoice::findOne($id);
+
+        if (!$replacementInvoice) {
+            $replacementInvoice = new ReplacementInvoice;
+        }
+        if ($replacementInvoice->load(Yii::$app->request->post())) {
+            $replacementInvoice->created_admin_id = Yii::$app->user->id;
+            $replacementInvoice->created_at = date('Y-m-d H:i:s');
+            $replacementInvoice->active = 1;
+
+            $exportImportTable = ExportImportTable::find()->select(['entity_id'])->where(['entity' => 'city_store', 'export_id' => 1, 'export_val' => $replacementInvoice->store_guid])->one();
+            if ($exportImportTable) {
+                $replacementInvoice->store_id = $exportImportTable->entity_id;
+            }
+            if ($replacementInvoice->validate()) {
+                $replacementInvoice->save();
+                ReplacementInvoiceProducts::deleteAll(['replacement_invoice_id' => $replacementInvoice->id]);
+                $modelsReplacementInvoiceProducts = MultipleModel::createMultipleModel(ReplacementInvoiceProducts::class,
+                    'ReplacementInvoice', 'replacementProducts');
+                $postReplacementInvoice = Yii::$app->request->post('ReplacementInvoice');
+                $loadDataReplacementInvoiceProducts = ArrayHelper::getValue($postReplacementInvoice, 'replacementProducts');
+                if (!empty($loadDataReplacementInvoiceProducts)) {
+                    MultipleModel::loadMultipleFromArray($modelsReplacementInvoiceProducts, $loadDataReplacementInvoiceProducts , '',[]);
+                }
+                foreach ($modelsReplacementInvoiceProducts as $key => $modelsReplacementInvoiceProduct) {
+                    /* @var $modelsReplacementInvoiceProduct ReplacementInvoiceProducts */
+                    $modelsReplacementInvoiceProduct->replacement_invoice_id = $replacementInvoice->id;
+                    $modelsReplacementInvoiceProduct->created_at = date('Y-m-d H:i:s');
+                    $modelsReplacementInvoiceProduct->created_admin_id = Yii::$app->user->id;
+                    if ($modelsReplacementInvoiceProduct->validate()) {
+                        $modelsReplacementInvoiceProduct->save();
+                    }
+                }
+                return $this->redirect(['/shift-transfer/invoice-view', 'id' => $replacementInvoice->id]);
+            }
+        }
+
+        $isCreate = false;
+
+        $storeNameById = TaskService::getEntitiesByAlias('store');
+
+        return $this->render('invoice-update',
+            compact('replacementInvoice', 'isCreate', 'storeNameById'));
+    }
+
+    public function actionInvoiceView($id) {
+        $replacementInvoice = ReplacementInvoice::findOne($id);
+
+        $storeNameById = TaskService::getEntitiesByAlias('store');
+
+        $admins = ArrayHelper::map(Admin::find()->all(), 'id', 'name');
+
+        return $this->render('invoice-view',
+            compact('replacementInvoice', 'storeNameById', 'admins'));
+    }
+
+    public function actionInvoiceDelete($id) {
+        ReplacementInvoice::deleteAll(['id' => $id]);
+
+        return $this->redirect(['/shift-transfer/invoice-index']);
+    }
+
 }
diff --git a/erp24/migrations/m241126_125723_create_table_shift_transfer_replacement_invoice.php b/erp24/migrations/m241126_125723_create_table_shift_transfer_replacement_invoice.php
new file mode 100755 (executable)
index 0000000..51c586e
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m241126_125723_create_table_shift_transfer_replacement_invoice
+ */
+class m241126_125723_create_table_shift_transfer_replacement_invoice extends Migration
+{
+    const TABLE_NAME  = 'erp24.replacement_invoice';
+    const TABLE_NAME2 = 'erp24.replacement_invoice_products';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $this->createTable(self::TABLE_NAME, [
+            'id' => $this->primaryKey()->comment('ID'),
+            'guid' => $this->string(100)->notNull()->unique()->comment('GUID документа для 1c'),
+            'status' => $this->integer()->notNull()->defaultValue(1)->comment('Статус документа'),
+            'created_admin_id' => $this->integer()->notNull()->comment('Создан пользователем'),
+            'updated_admin_id' => $this->integer()->null()->comment('Изменён пользователем'),
+            'confirm_admin_id' => $this->integer()->null()->comment('Подтвержден пользователем'),
+            'store_id' => $this->integer()->notNull()->comment('id магазина в ERP'),
+            'store_guid' => $this->string(100)->notNull()->comment('GUID магазина из 1с'),
+            'number' => $this->string(100)->notNull()->comment('Название документа'),
+            'number_1c' => $this->string(100)->null()->comment('Название документа в 1с'),
+            'date' => $this->dateTime()->notNull()->comment('Дата документа'),
+            'comment' => $this->text()->null()->comment('Комментарий'),
+            'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
+            'updated_at' => $this->dateTime()->null()->comment('Дата обновления'),
+            'deleted_at' => $this->dateTime()->null()->comment('Дата удаление'),
+            'send_at' => $this->dateTime()->null()->comment('Дата отправления в 1с'),
+            'active' => $this->tinyInteger()->notNull()->defaultValue(1)->comment('Активность'),
+            'deleted_admin_id' => $this->integer()->null()->comment('Удален пользователем'),
+        ]);
+
+        $this->createTable(self::TABLE_NAME2, [
+            'id' => $this->primaryKey()->comment('ID'),
+            'replacement_invoice_id' => $this->integer()->notNull()->comment('GUID документа из таблицы replacement_invoice'),
+            'name' => $this->string(100)->notNull()->comment('Название товара'),
+            'product_id' => $this->string(100)->notNull()->comment('GUID товара из таблицы products_1c'),
+            'direction_id' => $this->integer()->notNull()->comment('Направление передачи товара: 1 - списываемый товар, 2 - приходуемый товар'),
+            'quantity' => $this->float()->notNull()->comment('Количество'),
+            'price' => $this->float()->notNull()->comment('Цена'),
+            'price_retail' => $this->float()->null()->comment('Розничная цена'),
+            'price_self_cost' => $this->float()->null()->comment('Себестоимость'),
+            'summ' => $this->float()->notNull()->comment('Сумма'),
+            'summ_retail' => $this->float()->null()->comment('Сумма в розничных ценах'),
+            'summ_self_cost' => $this->float()->null()->comment('Сумма себестоимости'),
+            'active_product' => $this->tinyInteger()->notNull()->defaultValue(1)->comment('Активность'),
+            'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
+            'updated_at' => $this->dateTime()->null()->comment('Дата обновления'),
+            'deleted_at' => $this->dateTime()->null()->comment('Дата удаление'),
+            'created_admin_id' => $this->integer()->notNull()->comment('Создан пользователем'),
+            'updated_admin_id' => $this->integer()->null()->comment('Изменён пользователем'),
+            'deleted_admin_id' => $this->integer()->null()->comment('Удален пользователем'),
+        ]);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->dropTable(self::TABLE_NAME2);
+        $this->dropTable(self::TABLE_NAME);
+    }
+}
diff --git a/erp24/records/ReplacementInvoice.php b/erp24/records/ReplacementInvoice.php
new file mode 100644 (file)
index 0000000..dbbcb43
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "replacement_invoice".
+ *
+ * @property int $id ID
+ * @property string $guid GUID документа для 1c
+ * @property int $status Статус документа
+ * @property int $created_admin_id Создан пользователем
+ * @property int|null $updated_admin_id Изменён пользователем
+ * @property int|null $confirm_admin_id Подтвержден пользователем
+ * @property int $store_id id магазина в ERP
+ * @property string $store_guid GUID магазина из 1с
+ * @property string $number Название документа
+ * @property string|null $number_1c Название документа в 1с
+ * @property string $date Дата документа
+ * @property string|null $comment Комментарий
+ * @property string $created_at Дата создания
+ * @property string|null $updated_at Дата обновления
+ * @property string|null $deleted_at Дата удаление
+ * @property string|null $send_at Дата отправления в 1с
+ * @property int $active Активность
+ * @property int|null $deleted_admin_id Удален пользователем
+ */
+class ReplacementInvoice extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'replacement_invoice';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['guid', 'created_admin_id', 'store_id', 'store_guid', 'number', 'date', 'created_at'], 'required'],
+            [['status', 'created_admin_id', 'updated_admin_id', 'confirm_admin_id', 'store_id', 'active', 'deleted_admin_id'], 'default', 'value' => null],
+            [['status', 'created_admin_id', 'updated_admin_id', 'confirm_admin_id', 'store_id', 'active', 'deleted_admin_id'], 'integer'],
+            [['date', 'created_at', 'updated_at', 'deleted_at', 'send_at'], 'safe'],
+            [['comment'], 'string'],
+            [['guid', 'store_guid', 'number', 'number_1c'], 'string', 'max' => 100],
+            [['guid'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'guid' => 'Guid',
+            'status' => 'Status',
+            'created_admin_id' => 'Created Admin ID',
+            'updated_admin_id' => 'Updated Admin ID',
+            'confirm_admin_id' => 'Confirm Admin ID',
+            'store_id' => 'Store ID',
+            'store_guid' => 'Store Guid',
+            'number' => 'Number',
+            'number_1c' => 'Number 1c',
+            'date' => 'Date',
+            'comment' => 'Comment',
+            'created_at' => 'Created At',
+            'updated_at' => 'Updated At',
+            'deleted_at' => 'Deleted At',
+            'send_at' => 'Send At',
+            'active' => 'Active',
+            'deleted_admin_id' => 'Deleted Admin ID',
+        ];
+    }
+
+    public function getReplacementProducts() {
+        return $this->hasMany(ReplacementInvoiceProducts::class, ['replacement_invoice_id' => 'id']);
+    }
+}
diff --git a/erp24/records/ReplacementInvoiceProducts.php b/erp24/records/ReplacementInvoiceProducts.php
new file mode 100644 (file)
index 0000000..6686fe3
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "replacement_invoice_products".
+ *
+ * @property int $id ID
+ * @property int $replacement_invoice_id GUID документа из таблицы replacement_invoice
+ * @property string $name Название товара
+ * @property string $product_id GUID товара из таблицы products_1c
+ * @property int $direction_id Направление передачи товара: 1 - списываемый товар, 2 - приходуемый товар
+ * @property float $quantity Количество
+ * @property float $price Цена
+ * @property float|null $price_retail Розничная цена
+ * @property float|null $price_self_cost Себестоимость
+ * @property float $summ Сумма
+ * @property float|null $summ_retail Сумма в розничных ценах
+ * @property float|null $summ_self_cost Сумма себестоимости
+ * @property int $active_product Активность
+ * @property string $created_at Дата создания
+ * @property string|null $updated_at Дата обновления
+ * @property string|null $deleted_at Дата удаление
+ * @property int $created_admin_id Создан пользователем
+ * @property int|null $updated_admin_id Изменён пользователем
+ * @property int|null $deleted_admin_id Удален пользователем
+ */
+class ReplacementInvoiceProducts extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'replacement_invoice_products';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['replacement_invoice_id', 'name', 'product_id', 'direction_id', 'quantity', 'price', 'summ', 'created_at', 'created_admin_id'], 'required'],
+            [['replacement_invoice_id', 'direction_id', 'active_product', 'created_admin_id', 'updated_admin_id', 'deleted_admin_id'], 'default', 'value' => null],
+            [['replacement_invoice_id', 'direction_id', 'active_product', 'created_admin_id', 'updated_admin_id', 'deleted_admin_id'], 'integer'],
+            [['quantity', 'price', 'price_retail', 'price_self_cost', 'summ', 'summ_retail', 'summ_self_cost'], 'number'],
+            [['created_at', 'updated_at', 'deleted_at'], 'safe'],
+            [['name', 'product_id'], 'string', 'max' => 100],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'replacement_invoice_id' => 'Replacement Invoice ID',
+            'name' => 'Name',
+            'product_id' => 'Product ID',
+            'direction_id' => 'Direction ID',
+            'quantity' => 'Quantity',
+            'price' => 'Price',
+            'price_retail' => 'Price Retail',
+            'price_self_cost' => 'Price Self Cost',
+            'summ' => 'Summ',
+            'summ_retail' => 'Summ Retail',
+            'summ_self_cost' => 'Summ Self Cost',
+            'active_product' => 'Active Product',
+            'created_at' => 'Created At',
+            'updated_at' => 'Updated At',
+            'deleted_at' => 'Deleted At',
+            'created_admin_id' => 'Created Admin ID',
+            'updated_admin_id' => 'Updated Admin ID',
+            'deleted_admin_id' => 'Deleted Admin ID',
+        ];
+    }
+}
diff --git a/erp24/views/shift-transfer/invoice-index.php b/erp24/views/shift-transfer/invoice-index.php
new file mode 100644 (file)
index 0000000..9b5e79f
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+use yii\helpers\Url;
+use yii\helpers\Html;
+use yii\grid\GridView;
+use yii\data\ArrayDataProvider;
+use yii\grid\ActionColumn;
+use yii_app\records\ReplacementInvoice;
+
+/* @var $replacementInvoices []ReplacementInvoice */
+/* @var $storeNameById array */
+/* @var $admins array */
+
+?>
+
+<div class="shiftTransferInvoiceIndex m-5">
+
+    <h1>Накладные с товарами по заменам при передаче смен</h1>
+
+    <?= Html::a('Создать новую накладную с товарами по замене при передаче смен', '/shift-transfer/invoice-create', ['class' => 'btn btn-success']) ?>
+
+    <?= GridView::widget([
+        'dataProvider' => new ArrayDataProvider([
+            'allModels' => $replacementInvoices
+        ]),
+        'columns' => [
+            ['class' => 'yii\grid\SerialColumn'],
+            'id',
+            'guid',
+            'status',
+            [
+                'attribute' => 'created_admin_id',
+                'value' => function ($model) use ($admins) {
+                    return $admins[$model['created_admin_id']] ?? '';
+                }
+            ],
+            [
+                'attribute' => 'updated_admin_id',
+                'value' => function ($model) use ($admins) {
+                    return $admins[$model['updated_admin_id']] ?? '';
+                }
+            ],
+            [
+                'attribute' => 'confirm_admin_id',
+                'value' => function ($model) use ($admins) {
+                    return $admins[$model['confirm_admin_id']] ?? '';
+                }
+            ],
+            'store_id',
+            [
+                'attribute' => 'store_guid',
+                'label' => 'Магазин',
+                'value' => function ($model) use ($storeNameById) {
+                    return $storeNameById[$model['store_guid']] ?? '';
+                }
+            ],
+            'number',
+            'number_1c',
+            'date',
+            'comment',
+            'created_at',
+            'updated_at',
+            'deleted_at',
+            'send_at',
+            'active',
+            [
+                'attribute' => 'deleted_admin_id',
+                'value' => function ($model) use ($admins) {
+                    return $admins[$model['deleted_admin_id']] ?? '';
+                }
+            ],
+            [
+                'class' => ActionColumn::class,
+                'urlCreator' => function ($action, ReplacementInvoice $model, $key, $index, $column) {
+                    return Url::toRoute(['invoice-' . $action, 'id' => $model->id]);
+                }
+            ],
+        ]
+    ]) ?>
+
+</div>
diff --git a/erp24/views/shift-transfer/invoice-update.php b/erp24/views/shift-transfer/invoice-update.php
new file mode 100644 (file)
index 0000000..b7f04d5
--- /dev/null
@@ -0,0 +1,232 @@
+<?php
+
+use unclead\multipleinput\components\BaseColumn;
+use unclead\multipleinput\MultipleInput;
+
+use yii\helpers\ArrayHelper;
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+
+use kartik\select2\Select2;
+use dosamigos\datetimepicker\DateTimePicker;
+use yii_app\records\Products1c;
+use yii_app\records\ReplacementInvoice;
+
+/* @var $isCreate bool */
+/* @var $replacementInvoice ReplacementInvoice */
+/* @var $storeNameById array */
+
+$this->registerJsFile('/js/shift-transfer/invoice-update.js', ['position' => \yii\web\View::POS_END]);
+
+$this->registerCss('
+    .multiple-input-list__btn.js-input-plus.btn.btn-success {
+        display: block !important;
+        width: 40px;
+    }
+');
+?>
+
+<div class="shiftTransferInvoiceCreate m-5">
+
+    <?= Html::a('Назад', '/shift-transfer/invoice-index', ['class' => 'btn btn-secondary']) ?>
+
+    <h1><?= $isCreate ? 'Создание' : 'Обновление' ?> замены товаров при передаче смены</h1>
+
+    <?php $form = ActiveForm::begin([
+        'action' => ['/shift-transfer/invoice-update', 'id' => Yii::$app->request->get('id')],
+    ]) ?>
+
+    <?= $form->field($replacementInvoice, 'id')->hiddenInput()->label(false) ?>
+
+    <div class="row">
+        <div class="col-4">
+            <?= $form->field($replacementInvoice, 'guid')->textInput() ?>
+        </div>
+        <div class="col-4">
+            <?= $form->field($replacementInvoice, 'status')->textInput() ?>
+        </div>
+        <div class="col-4">
+            <?= $form->field($replacementInvoice, 'store_guid')->dropDownList($storeNameById) ?>
+        </div>
+    </div>
+
+    <div class="row">
+        <div class="col-4">
+            <?= $form->field($replacementInvoice, 'number')->textInput() ?>
+        </div>
+        <div class="col-4">
+            <?= $form->field($replacementInvoice, 'number_1c')->textInput() ?>
+        </div>
+        <div class="col-4">
+            <?= $form->field($replacementInvoice, 'date')->widget(DateTimePicker::class, [
+                'language' => 'ru',
+                'template' => '{input}',
+                'clientOptions' => [
+                    'autoclose' => true,
+                    'format' => 'Y-m-d H:i:s',
+                    'todayBtn' => true
+                ],
+            ]) ?>
+        </div>
+    </div>
+
+    <div class="row">
+        <div class="col-6">
+            <?= $form->field($replacementInvoice, 'comment')->textarea(['rows' => 6]) ?>
+        </div>
+    </div>
+
+    <div class="row">
+        <div class="col-12">
+        <?= $form->field($replacementInvoice, 'replacementProducts')->widget(MultipleInput::class, [
+            'min' => 0,
+            'max' => 100,
+            'columns' => [
+                [
+                    'name'  => 'name',
+                    'title' => 'Название',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'value' => function($data) {
+                        return $data['name'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'product_id',
+                    'title' => 'Продукт',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'value' => function($data) {
+                        return $data['product_id'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'direction_id',
+                    'title' => 'Направление передачи товара',
+                    'type'  => BaseColumn::TYPE_DROPDOWN,
+                    'items' => [1 => 'списываемый', 2 => 'приходуемый'],
+                    'value' => function($data) {
+                        return $data['direction_id'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'quantity',
+                    'title' => 'Кол-во, шт',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'value' => function($data) {
+                        return $data['quantity'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'price',
+                    'title' => 'Цена, руб',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'value' => function($data) {
+                        return $data['price'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'price_retail',
+                    'title' => 'Розничная цена, руб',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'value' => function($data) {
+                        return $data['price_retail'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'price_self_cost',
+                    'title' => 'Себестоимость, руб',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'value' => function($data) {
+                        return $data['price_self_cost'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'summ',
+                    'title' => 'Сумма, руб',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'value' => function($data) {
+                        return $data['summ'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'summ_retail',
+                    'title' => 'Сумма в розничных ценах, руб',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'value' => function($data) {
+                        return $data['summ_retail'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'summ_self_cost',
+                    'title' => 'Сумма себестоимости, руб',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'value' => function($data) {
+                        return $data['summ_self_cost'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+                [
+                    'name'  => 'active_product',
+                    'title' => 'Активность',
+                    'type'  => BaseColumn::TYPE_CHECKBOX,
+                    'options' => ['uncheck' => 0],
+                    'value' => function($data) {
+                        return $data['active_product'] ?? '';
+                    },
+                    'headerOptions' => [
+                        'style' => 'width: 70px;',
+                    ]
+                ],
+            ],
+            'addButtonPosition' => MultipleInput::POS_FOOTER,
+            'addButtonOptions' => [
+                'class' => 'btn btn-success visible',
+                'style' => 'display:block; width: 250px;',
+            ],
+            'iconSource'=> 'fa',
+        ])->label(false);?>
+        </div>
+    </div>
+
+    <div class="form-group">
+        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+    </div>
+
+    <?php ActiveForm::end() ?>
+
+</div>
diff --git a/erp24/views/shift-transfer/invoice-view.php b/erp24/views/shift-transfer/invoice-view.php
new file mode 100644 (file)
index 0000000..98d7f9f
--- /dev/null
@@ -0,0 +1,179 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+use yii\helpers\ArrayHelper;
+use yii_app\records\ReplacementInvoice;
+use yii_app\records\ProductsClass;
+use yii_app\records\Products1c;
+
+/* @var $replacementInvoice ReplacementInvoice */
+/* @var $storeNameById array */
+/* @var $admins array */
+
+?>
+
+<div class="shiftTransferInvoiceView m-5">
+
+    <?= Html::a('Назад', '/shift-transfer/invoice-index', ['class' => 'btn btn-secondary']) ?>
+    <?= Html::a('Редактировать', ['/shift-transfer/invoice-update', 'id' => Yii::$app->request->get('id')], ['class' => 'btn btn-primary']) ?>
+
+    <h1>Просмотр накладной с товарами по заменам при передаче смены</h1>
+
+    <?= DetailView::widget([
+        'model' => $replacementInvoice,
+        'attributes' => [
+            'guid',
+            'status',
+            [
+                'attribute' => 'created_admin_id',
+                'value' => function ($model) use ($admins) {
+                    return $admins[$model['created_admin_id']] ?? '';
+                }
+            ],
+            [
+                'attribute' => 'updated_admin_id',
+                'value' => function ($model) use ($admins) {
+                    return $admins[$model['updated_admin_id']] ?? '';
+                }
+            ],
+            [
+                'attribute' => 'confirm_admin_id',
+                'value' => function ($model) use ($admins) {
+                    return $admins[$model['confirm_admin_id']] ?? '';
+                }
+            ],
+            [
+                'label' => 'Магазин',
+                'attribute' => 'store_guid',
+                'value' => function ($model) use ($storeNameById) {
+                    return $storeNameById[$model['store_guid']] ?? '';
+                }
+            ],
+            'number',
+            'number_1c',
+            'date',
+            'comment',
+        ]
+    ]) ?>
+
+    <div class="row">
+        <div class="col-12">
+            <?= \kartik\grid\GridView::widget([
+                'dataProvider' => new \yii\data\ArrayDataProvider([
+                    'allModels' => $replacementInvoice->replacementProducts
+                ]),
+//                'showFooter' => true,
+                'columns' => [
+                    [
+                        'attribute'  => 'name',
+                        'label' => 'Название',
+//                        'footer' => 'Итого:',
+                        'pageSummary' => 'Итого:',
+                        'value' => function($data) {
+                            return $data['name'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'product_id',
+                        'label' => 'Продукт',
+                        'value' => function($data) {
+                            $products = ArrayHelper::map(Products1c::find()->select(['id', 'name'])->all(), 'id', 'name');
+                            return $products[$data['product_id']] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'direction_id',
+                        'label' => 'Направление передачи товара',
+                        'value' => function($data) {
+                            return [1 => 'списываемый', 2 => 'приходуемый'][$data['direction_id']] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'quantity',
+                        'label' => 'Кол-во, шт',
+                        'pageSummary' => true,
+                        'value' => function($data) {
+                            return $data['quantity'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'price',
+                        'label' => 'Цена, руб',
+                        'pageSummary' => true,
+                        'value' => function($data) {
+                            return $data['price'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'price_retail',
+                        'label' => 'Розничная цена, руб',
+                        'pageSummary' => true,
+                        'value' => function($data) {
+                            return $data['price_retail'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'price_self_cost',
+                        'label' => 'Себестоимость, руб',
+                        'pageSummary' => true,
+                        'value' => function($data) {
+                            return $data['price_self_cost'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'active_product',
+                        'label' => 'Активность',
+                        'value' => function($data) {
+                            return $data['active_product'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'created_at',
+                        'label' => 'Создано в',
+                        'value' => function($data) {
+                            return $data['created_at'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'updated_at',
+                        'label' => 'Обновлено в',
+                        'value' => function($data) {
+                            return $data['updated_at'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'deleted_at',
+                        'label' => 'Удалено в',
+                        'value' => function($data) {
+                            return $data['deleted_at'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'created_admin_id',
+                        'label' => 'Создано кем',
+                        'value' => function($data) {
+                            return $data['created_admin_id'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'updated_admin_id',
+                        'label' => 'Обновлено кем',
+                        'value' => function($data) {
+                            return $data['updated_admin_id'] ?? '';
+                        },
+                    ],
+                    [
+                        'attribute'  => 'deleted_admin_id',
+                        'label' => 'Удалено кем',
+                        'value' => function($data) {
+                            return $data['deleted_admin_id'] ?? '';
+                        },
+                    ],
+                ],
+                'showPageSummary' => true,
+            ]); ?>
+        </div>
+    </div>
+
+</div>
diff --git a/erp24/web/js/shift-transfer/invoice-update.js b/erp24/web/js/shift-transfer/invoice-update.js
new file mode 100644 (file)
index 0000000..352b40e
--- /dev/null
@@ -0,0 +1,2 @@
+/* jshint esversion: 6 */
+