From: marina Date: Mon, 9 Dec 2024 08:02:31 +0000 (+0300) Subject: ERP-259 Доработка второго шага передачи смен X-Git-Tag: 1.7~187^2~2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=0a4ebd1ee4d8f0c2fa2890981b71c4578a9c10cd;p=erp24_rep%2Fyii-erp24%2F.git ERP-259 Доработка второго шага передачи смен --- diff --git a/erp24/controllers/ShiftTransferController.php b/erp24/controllers/ShiftTransferController.php index 3456826d..8044e05d 100644 --- a/erp24/controllers/ShiftTransferController.php +++ b/erp24/controllers/ShiftTransferController.php @@ -30,13 +30,15 @@ use yii_app\services\TaskService; class ShiftTransferController extends Controller { - public static function isAllowedAdmin() { + public static function isAllowedAdmin() + { $admin = Admin::findOne(Yii::$app->user->id); return !(!$admin || $admin->group_id == -1 || !in_array($admin->group_id, - array_merge(Admin::ADMIN_CABINET_GROUP_IDS, [AdminGroup::GROUP_IT, AdminGroup::GROUP_ADMINISTRATORS]))); + array_merge(Admin::ADMIN_CABINET_GROUP_IDS, [AdminGroup::GROUP_IT, AdminGroup::GROUP_ADMINISTRATORS]))); } - public function actionIndex() { + public function actionIndex() + { if (!self::isAllowedAdmin()) { return 'Нет доступа'; } @@ -51,11 +53,12 @@ class ShiftTransferController extends Controller return $this->render('index', compact('shiftTransfers', 'storeNameById', 'admins')); } - public function buildLoadDataShiftRemains($groups, $storeGuid) { + public function buildLoadDataShiftRemains($groups, $storeGuid) + { $productsClass = ProductsClass::find()->select(['category_id'])->where(['tip' => $groups])->column(); $products = ArrayHelper::map(Products1c::find()->alias('p')->select(['id', 'name'])->leftJoin('products_class pc', 'pc.category_id = p.parent_id') ->where(['parent_id' => $productsClass])->orderBy(['(CASE WHEN pc.tip = \'other_items\' THEN 1 ELSE 0 END)' => SORT_DESC - ,'name' => SORT_ASC])->all(), 'id', 'name'); + , 'name' => SORT_ASC])->all(), 'id', 'name'); $balance = ArrayHelper::map(Balances::find()->select(['quantity', 'product_id']) ->where(['store_id' => $storeGuid])->all(), 'product_id', 'quantity'); $productGuids = []; @@ -74,10 +77,10 @@ class ShiftTransferController extends Controller $loadDataShiftRemains = []; foreach ($productGuids as $key => $name) { - $loadDataShiftRemains[]= [ + $loadDataShiftRemains[] = [ 'product_guid' => $key, 'retail_price' => $price[$key] ?? '', 'self_cost' => $selfCost[$key] ?? '', - 'remains_summ' => isset($price[$key]) && isset($balance[$key]) ? $price[$key] * $balance[$key]: '', + 'remains_summ' => isset($price[$key]) && isset($balance[$key]) ? $price[$key] * $balance[$key] : '', 'remains_count' => $balance[$key] ?? '', 'fact_and_1c_diff' => 0, 'remains_1c' => $balance[$key] ?? '' ]; @@ -158,7 +161,7 @@ class ShiftTransferController extends Controller } } - EqualizationRemains::setData($shiftTransfer); + EqualizationRemains::setData($shiftTransfer); if ($shiftTransfer->validate()) { $shiftTransfer->goods_transfer_count = array_sum(ArrayHelper::getColumn($shiftTransfer->shiftRemains, 'remains_count')); @@ -197,7 +200,6 @@ class ShiftTransferController extends Controller } - public function actionGetProductPriceSelfCostAndRemains() { Yii::$app->response->format = Response::FORMAT_JSON; @@ -219,7 +221,8 @@ class ShiftTransferController extends Controller return ['groupLabel' => $productClass->tip ?? 'other_items', 'price' => $price->price ?? 0, 'selfCost' => $selfCost->price ?? 0, 'quantity' => $balance->quantity ?? 0]; } - public function actionGetProductsWithRemains() { + public function actionGetProductsWithRemains() + { Yii::$app->response->format = Response::FORMAT_JSON; $storeGuid = Yii::$app->request->post('storeGuid'); $balance = ArrayHelper::map(Balances::find()->select(['quantity', 'product_id'])->where(['store_id' => $storeGuid])->all(), 'product_id', 'quantity'); @@ -249,6 +252,9 @@ class ShiftTransferController extends Controller } elseif ($action === 'save') { $model->updateAttributes(['status_id' => ShiftTransfer::STATUS_ID_READY_TO_ACCEPT]); EqualizationRemains::updateData(Yii::$app->request->post()['ShiftTransfer']['equalizationRemains'], $id); + } elseif ($action == 'recalculate') { + EqualizationRemains::setData($model); + Yii::$app->session->setFlash('success', 'Таблица замен успешно перерасчитана'); } elseif ($action === 'rejection') { $model->updateAttributes(['status_id' => ShiftTransfer::STATUS_ID_TRANSFER_ACTIONS]); } diff --git a/erp24/views/shift-transfer/_replacement.php b/erp24/views/shift-transfer/_replacement.php index e18038eb..e878622d 100644 --- a/erp24/views/shift-transfer/_replacement.php +++ b/erp24/views/shift-transfer/_replacement.php @@ -6,6 +6,7 @@ use unclead\multipleinput\components\BaseColumn; use unclead\multipleinput\MultipleInput; use yii\data\ArrayDataProvider; use yii\helpers\Html; +use yii\helpers\Url; use yii_app\records\ShiftTransfer; use yii\widgets\ActiveForm; @@ -19,9 +20,32 @@ $this->registerJsFile('/js/shift-transfer/replacement.js', ['position' => \yii\w $totalBalance = array_sum(array_column($shiftTransfer->equalizationRemains, 'balance')); -$form = \yii\widgets\ActiveForm::begin(); +$form = \yii\widgets\ActiveForm::begin(); ?> + +
+
+ + +
+ + +
+status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIONS, ShiftTransfer::STATUS_ID_INPUT_FACT_REMAINS]) && Yii::$app->user->id === $shiftTransfer->end_shift_admin_id) { + + echo Html::submitButton('Пересчитать таблицу замен', [ + 'class' => 'btn btn-primary float-right', + 'name' => 'action', + 'value' => 'recalculate' + ]); ?> +
+
+ field($shiftTransfer, 'equalizationRemains')->widget(MultipleInput::class, [ 'min' => 0, 'max' => 100, @@ -141,15 +165,20 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO 'class' => 'btn btn-danger visible', ], 'iconSource' => 'fa', - ])->label('Таблица возможных замен'); + ])->label(false); echo $btn = Html::submitButton('Сохранить', [ 'class' => 'btn btn-primary float-right', 'name' => 'action', 'value' => 'save' ]); + ?> + + + + new ArrayDataProvider([ 'allModels' => $shiftTransfer->equalizationRemains, diff --git a/erp24/views/shift-transfer/view.php b/erp24/views/shift-transfer/view.php index ba8fbb8b..ca55f8eb 100644 --- a/erp24/views/shift-transfer/view.php +++ b/erp24/views/shift-transfer/view.php @@ -21,6 +21,13 @@ $this->registerCss('
+ session->hasFlash('success')): ?> +
+ + session->getFlash('success') ?> +
+ + session->hasFlash('info')): ?>
@@ -29,7 +36,7 @@ $this->registerCss(' 'btn btn-secondary']) ?> - status_id,[ShiftTransfer::STATUS_ID_INPUT_FACT_REMAINS, ShiftTransfer::STATUS_ID_TRANSFER_ACTIONS]) && ShiftTransferController::isAllowedAdmin() ? Html::a('Редактировать', ['/shift-transfer/update', 'id' => Yii::$app->request->get('id')], ['class' => 'btn btn-primary']) : '' ?> + status_id, [ShiftTransfer::STATUS_ID_INPUT_FACT_REMAINS, ShiftTransfer::STATUS_ID_TRANSFER_ACTIONS]) && ShiftTransferController::isAllowedAdmin() ? Html::a('Редактировать', ['/shift-transfer/update', 'id' => Yii::$app->request->get('id')], ['class' => 'btn btn-primary']) : '' ?>

Просмотр передачи смены