]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-243 Действия по замене (II этап)
authormarina <m.zozirova@gmail.com>
Tue, 3 Dec 2024 13:49:01 +0000 (16:49 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 3 Dec 2024 13:49:01 +0000 (16:49 +0300)
erp24/controllers/ShiftTransferController.php
erp24/records/ReplacementInvoice.php
erp24/records/ReplacementInvoiceProducts.php
erp24/records/StoreBalance.php
erp24/views/replacement-invoice/view.php
erp24/views/shift-transfer/_replacement.php
erp24/views/store-balance/index.php
erp24/views/store-balance/view.php

index dbe69cca2fa3e9c35353d16d7b7bc52f4e127e17..bff9fb0fbd57c47277ca481850fcdbe608d06be0 100644 (file)
@@ -174,6 +174,8 @@ class ShiftTransferController extends Controller
             } elseif ($action === 'rejection') {
                 $model->updateAttributes(['status_id' => ShiftTransfer::STATUS_ID_TRANSFER_ACTIONS]);
             }
+
+            $this->redirect(Yii::$app->request->referrer);
         }
 
         $shiftTransfer = ShiftTransfer::findOne($id);
index e088fd0e7ad4455d776881477490e292ff0e6760..556ef76f93a08ab410901fd28ecfd98f9c47c576 100644 (file)
@@ -87,7 +87,6 @@ class ReplacementInvoice extends \yii\db\ActiveRecord
             'created_admin_id' => $shiftTransfer->end_shift_admin_id,
             'updated_admin_id' => $shiftTransfer->start_shift_admin_id,
             'confirm_admin_id' => $shiftTransfer->start_shift_admin_id,
-            'number' => $guid,
             'store_id' => $storeId,
             'store_guid' => $shiftTransfer->store_guid,
             'date' => $shiftTransfer->date,
@@ -98,6 +97,9 @@ class ReplacementInvoice extends \yii\db\ActiveRecord
 
         if ($model->validate()) {
             $model->save();
+            $model->update([
+                'number' => 'ЕРП_ПС_' . date("Y-m-d_H-i") . $model->id,
+            ]);
             ReplacementInvoiceProducts::setData($model, $shiftTransfer);
         } else {
             var_dump($model->getErrors());
index 2f8065e779db60003e0fdc0a8cca3d3e7b1e4365..c06dfbb5b08445e036bc059a4eebff8fe74dfcf1 100644 (file)
@@ -141,24 +141,24 @@ class ReplacementInvoiceProducts extends \yii\db\ActiveRecord
     {
         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',
+            'replacement_invoice_id' => 'ID заменяющего счета',
+            'name' => 'Название товара',
+            'product_id' => 'GUID товара',
+            'direction_id' => 'Направление передачи товара',
+            'quantity' => 'Количество',
+            'price' => 'Цена',
+            'price_retail' => 'Розничная цена',
+            'price_self_cost' => 'Себестоимость',
+            'summ' => 'Сумма',
+            'summ_retail' => 'Сумма по розничной цене',
+            'summ_self_cost' => 'Сумма себестоимости',
+            'active_product' => 'Активность товара',
+            'created_at' => 'Дата создания',
+            'updated_at' => 'Дата обновления',
+            'deleted_at' => 'Дата удаления',
+            'created_admin_id' => 'Создан пользователем',
+            'updated_admin_id' => 'Изменен пользователем',
+            'deleted_admin_id' => 'Удален пользователем',
         ];
     }
 
index 83a9a532ad12a9437e95d81f6850b30f424e48c3..61ed1f832a052a992243df25f1b9945b7e038078 100644 (file)
@@ -37,23 +37,26 @@ class StoreBalance extends \yii\db\ActiveRecord
 
     public static function setData($shiftTransfer)
     {
-
         $equalizationData = EqualizationRemains::find()
             ->where(['shift_id' => $shiftTransfer->id])
+            ->leftJoin('products_1c AS product', 'product.id = equalization_remains.product_id')
+            ->leftJoin('products_1c AS product_replacement', 'product_replacement.id = equalization_remains.product_replacement_id')
             ->select([
-                'product_id',
-                'product_count',
-                'product_price',
-                'product_self_cost',
-                'product_replacement_id',
-                'product_replacement_count',
-                'product_replacement_price',
-                'product_replacement_self_cost',
-                'balance',
-                'balance_self_cost'
+                'equalization_remains.product_id',
+                'product.name AS product_name',
+                'equalization_remains.product_count',
+                'equalization_remains.product_price',
+                'equalization_remains.product_self_cost',
+                'equalization_remains.product_replacement_id',
+                'product_replacement.name AS product_replacement_name',
+                'equalization_remains.product_replacement_count',
+                'equalization_remains.product_replacement_price',
+                'equalization_remains.product_replacement_self_cost',
+                'equalization_remains.balance',
+                'equalization_remains.balance_self_cost'
             ])
             ->asArray()
-            ->all() ?? '';
+            ->all();
 
         $articule = implode(';', array_map(fn($equalizationRemain) =>
                 $equalizationRemain->product->articule . '=>' . $equalizationRemain->productReplacement->articule,
@@ -70,7 +73,7 @@ class StoreBalance extends \yii\db\ActiveRecord
                 ->scalar() ?? '',
             'status_id' => self::STATUS_NEW,
             'comment' => $shiftTransfer->comment,
-            'json' => json_encode($equalizationData),
+            'json' => json_encode($equalizationData, JSON_UNESCAPED_UNICODE),
             'replace_articule' => $articule,
             'type_id' => self::REPLACEMENT_ACTIONS,
         ]);
index c4993b4102ba8197df0f637c6f79360478211944..e8e735bcb4c04d0287228693e3ab1cbb68e55328 100644 (file)
@@ -106,7 +106,6 @@ $this->params['breadcrumbs'][] = $this->title;
                     return $model->summ_self_cost ?? 'N/A';
                 },
             ],
-            'active_product:boolean',
             'updated_at:datetime',
             [
                 'attribute' => 'updated_admin_id',
@@ -114,7 +113,6 @@ $this->params['breadcrumbs'][] = $this->title;
                     return $model->updatedAdmin->name_full;
                 },
             ],
-            ['class' => 'yii\grid\ActionColumn'],
         ],
     ]); ?>
 </div>
index e22c7c37970ec246cc8006a0032c07d390a998bd..f1d2e1accc5f8909914d64f1a6c8755b12b320c5 100644 (file)
@@ -228,7 +228,11 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
         'layout' => '{items}',
     ]);
 
-    if (in_array(Yii::$app->user->id, $usersOnStoreArray) && $shiftTransfer->status_id == ShiftTransfer::STATUS_ID_READY_TO_ACCEPT) {
+    if (
+        in_array(Yii::$app->user->id, $usersOnStoreArray)
+        && $shiftTransfer->status_id == ShiftTransfer::STATUS_ID_READY_TO_ACCEPT
+        && Yii::$app->user->id != $shiftTransfer->end_shift_admin_id
+    ) {
         echo Html::submitButton('Принять', [
                 'class' => 'btn btn-primary float-right',
                 'name' => 'action',
index 55b5f054b84af3696afb861a2652ddc965734273..c8fd35ff58e990f161384526e10b9e2af01b2087 100644 (file)
@@ -2,6 +2,7 @@
 
 use yii\helpers\Html;
 use yii\grid\GridView;
+use yii_app\records\CityStore;
 
 /* @var $this yii\web\View */
 /* @var $dataProvider yii\data\ActiveDataProvider */
@@ -16,15 +17,35 @@ $this->params['breadcrumbs'][] = $this->title;
     <?= GridView::widget([
         'dataProvider' => $dataProvider,
         'columns' => [
-            ['class' => 'yii\grid\SerialColumn'],
 
             'id',
-            'store_id',
-            'shift_id',
+            [
+                'attribute' => 'store_id',
+                'value' => function ($model) {
+        return CityStore::findOne(\yii_app\records\ExportImportTable::findOne(['export_val' => $model->store_id])->entity_id)->name;
+                }
+            ],
+            [
+                'attribute' => 'shift_id',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return \yii\helpers\Html::a("Передача смены #$model->shift_id", ['shift-transfer/view', 'id' => $model->shift_id]);
+                }
+            ],
             'date',
             'amount',
-            'status_id',
-            'type_id',
+            [
+                'attribute' => 'status_id',
+                'value' => function ($model) {
+                    return $model->status_id  == \yii_app\records\StoreBalance::STATUS_NEW ? 'Новая' : $model->status_id;
+                }
+            ],
+            [
+                'attribute' => 'type_id',
+                'value' => function ($model) {
+                    return $model->type_id  == \yii_app\records\StoreBalance::REPLACEMENT_ACTIONS ? 'Действия по замене' : $model->type_id;
+                }
+            ],
             'comment_controler',
             [
                 'class' => 'yii\grid\ActionColumn',
index d593eebbee84b99ec0e815e43426e3c37be198b7..ec596729d1c45dbfd9500309fefb28fcfe1baf2e 100644 (file)
@@ -1,11 +1,13 @@
 <?php
 
 use yii\helpers\Html;
+use yii\widgets\DetailView;
+use yii_app\records\CityStore;
 
 /* @var $this yii\web\View */
 /* @var $model app\models\StoreBalance */
 
-$this->title = 'Детали баланса магазина: ' . $model->id;
+$this->title = 'Детали баланса магазина # ' . $model->id;
 $this->params['breadcrumbs'][] = ['label' => 'Баланс магазинов', 'url' => ['index']];
 $this->params['breadcrumbs'][] = $this->title;
 ?>
@@ -17,54 +19,51 @@ $this->params['breadcrumbs'][] = $this->title;
         <?= Html::a('Вернуться к списку', ['index'], ['class' => 'btn btn-primary']) ?>
     </p>
 
-    <table class="table table-striped">
-        <tr>
-            <th>ID</th>
-            <td><?= Html::encode($model->id) ?></td>
-        </tr>
-        <tr>
-            <th>Магазин</th>
-            <td><?= Html::encode($model->store_id) ?></td>
-        </tr>
-        <tr>
-            <th>Смена</th>
-            <td><?= Html::encode($model->shift_id) ?></td>
-        </tr>
-        <tr>
-            <th>Дата</th>
-            <td><?= Html::encode($model->date) ?></td>
-        </tr>
-        <tr>
-            <th>Сумма</th>
-            <td><?= Html::encode($model->amount) ?></td>
-        </tr>
-        <tr>
-            <th>Статус</th>
-            <td><?= Html::encode($model->status_id) ?></td>
-        </tr>
-        <tr>
-            <th>Комментарий</th>
-            <td><?= Html::encode($model->comment) ?></td>
-        </tr>
-        <tr>
-            <th>JSON</th>
-            <td><?= Html::encode($model->json) ?></td>
-        </tr>
-        <tr>
-            <th>Заменить товары</th>
-            <td><?= Html::encode($model->replace_articule) ?></td>
-        </tr>
-        <tr>
-            <th>Комментарий контролера</th>
-            <td><?= Html::encode($model->comment_controler) ?></td>
-        </tr>
-        <tr>
-            <th>ID контролера</th>
-            <td><?= Html::encode($model->controler_id) ?></td>
-        </tr>
-        <tr>
-            <th>Тип</th>
-            <td><?= Html::encode($model->type_id) ?></td>
-        </tr>
-    </table>
+    <?= DetailView::widget([
+        'model' => $model,
+        'attributes' => [
+            [
+                'attribute' => 'store_id',
+                'value' => function ($model) {
+                    // Для отображения магазина с учетом связанной таблицы
+                    return CityStore::findOne(\yii_app\records\ExportImportTable::findOne(['export_val' => $model->store_id])->entity_id)->name;
+                }
+            ],
+            [
+                'attribute' => 'shift_id',
+                'value' => function ($model) {
+                    // Если требуется вывести ссылку на смену
+                    return Html::a("Передача смены #$model->shift_id", ['shift-transfer/view', 'id' => $model->shift_id]);
+                },
+                'format' => 'raw', // Позволяет выводить HTML, то есть ссылку
+            ],
+            'date',
+            'amount',
+            [
+                'attribute' => 'status_id',
+                'value' => function ($model) {
+                    return $model->status_id == \yii_app\records\StoreBalance::STATUS_NEW ? 'Новая' : $model->status_id;
+                }
+            ],
+            [
+                'attribute' => 'type_id',
+                'value' => function ($model) {
+                    return $model->type_id == \yii_app\records\StoreBalance::REPLACEMENT_ACTIONS ? 'Действия по замене' : $model->type_id;
+                }
+            ],
+            'comment',
+            [
+                'attribute' => 'json',
+                'value' => function ($model) {
+                    $jsonArray = json_decode($model->json, true);
+                    return Html::tag('pre', json_encode($jsonArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
+                },
+                'format' => 'raw',
+            ],
+            'replace_articule',
+            'comment_controler',
+            'controler_id',
+        ],
+    ]) ?>
+
 </div>