From 00b5f12577ff018c6f6f8958ca8c9f67eea5d421 Mon Sep 17 00:00:00 2001
From: marina
Date: Tue, 3 Dec 2024 16:49:01 +0300
Subject: [PATCH] =?utf8?q?ERP-243=20=D0=94=D0=B5=D0=B9=D1=81=D1=82=D0=B2?=
=?utf8?q?=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD?=
=?utf8?q?=D0=B5=20(II=20=D1=8D=D1=82=D0=B0=D0=BF)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
---
erp24/controllers/ShiftTransferController.php | 2 +
erp24/records/ReplacementInvoice.php | 4 +-
erp24/records/ReplacementInvoiceProducts.php | 36 +++----
erp24/records/StoreBalance.php | 29 ++---
erp24/views/replacement-invoice/view.php | 2 -
erp24/views/shift-transfer/_replacement.php | 6 +-
erp24/views/store-balance/index.php | 31 +++++-
erp24/views/store-balance/view.php | 101 +++++++++---------
8 files changed, 120 insertions(+), 91 deletions(-)
diff --git a/erp24/controllers/ShiftTransferController.php b/erp24/controllers/ShiftTransferController.php
index dbe69cca..bff9fb0f 100644
--- a/erp24/controllers/ShiftTransferController.php
+++ b/erp24/controllers/ShiftTransferController.php
@@ -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);
diff --git a/erp24/records/ReplacementInvoice.php b/erp24/records/ReplacementInvoice.php
index e088fd0e..556ef76f 100644
--- a/erp24/records/ReplacementInvoice.php
+++ b/erp24/records/ReplacementInvoice.php
@@ -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());
diff --git a/erp24/records/ReplacementInvoiceProducts.php b/erp24/records/ReplacementInvoiceProducts.php
index 2f8065e7..c06dfbb5 100644
--- a/erp24/records/ReplacementInvoiceProducts.php
+++ b/erp24/records/ReplacementInvoiceProducts.php
@@ -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' => 'Удален полÑзоваÑелем',
];
}
diff --git a/erp24/records/StoreBalance.php b/erp24/records/StoreBalance.php
index 83a9a532..61ed1f83 100644
--- a/erp24/records/StoreBalance.php
+++ b/erp24/records/StoreBalance.php
@@ -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,
]);
diff --git a/erp24/views/replacement-invoice/view.php b/erp24/views/replacement-invoice/view.php
index c4993b41..e8e735bc 100644
--- a/erp24/views/replacement-invoice/view.php
+++ b/erp24/views/replacement-invoice/view.php
@@ -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'],
],
]); ?>
diff --git a/erp24/views/shift-transfer/_replacement.php b/erp24/views/shift-transfer/_replacement.php
index e22c7c37..f1d2e1ac 100644
--- a/erp24/views/shift-transfer/_replacement.php
+++ b/erp24/views/shift-transfer/_replacement.php
@@ -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',
diff --git a/erp24/views/store-balance/index.php b/erp24/views/store-balance/index.php
index 55b5f054..c8fd35ff 100644
--- a/erp24/views/store-balance/index.php
+++ b/erp24/views/store-balance/index.php
@@ -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',
diff --git a/erp24/views/store-balance/view.php b/erp24/views/store-balance/view.php
index d593eebb..ec596729 100644
--- a/erp24/views/store-balance/view.php
+++ b/erp24/views/store-balance/view.php
@@ -1,11 +1,13 @@
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']) ?>
-
-
- | ID |
- = Html::encode($model->id) ?> |
-
-
- | Ðагазин |
- = Html::encode($model->store_id) ?> |
-
-
- | Смена |
- = Html::encode($model->shift_id) ?> |
-
-
- | ÐаÑа |
- = Html::encode($model->date) ?> |
-
-
- | СÑмма |
- = Html::encode($model->amount) ?> |
-
-
- | СÑаÑÑÑ |
- = Html::encode($model->status_id) ?> |
-
-
- | ÐомменÑаÑий |
- = Html::encode($model->comment) ?> |
-
-
- | JSON |
- = Html::encode($model->json) ?> |
-
-
- | ÐамениÑÑ ÑоваÑÑ |
- = Html::encode($model->replace_articule) ?> |
-
-
- | ÐомменÑаÑий конÑÑолеÑа |
- = Html::encode($model->comment_controler) ?> |
-
-
- | ID конÑÑолеÑа |
- = Html::encode($model->controler_id) ?> |
-
-
- | Тип |
- = Html::encode($model->type_id) ?> |
-
-
+ = 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',
+ ],
+ ]) ?>
+
--
2.39.5