From: Aleksey Filippov Date: Thu, 12 Jun 2025 20:49:41 +0000 (+0300) Subject: Исправление ошибки блокировки кнопки списания X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=46763622102a67c49517fd7f2d0ebac1677be99d;p=erp24_rep%2Fyii-erp24%2F.git Исправление ошибки блокировки кнопки списания --- diff --git a/erp24/controllers/WriteOffsErpController.php b/erp24/controllers/WriteOffsErpController.php index c2d03a2b..b7a4dc44 100644 --- a/erp24/controllers/WriteOffsErpController.php +++ b/erp24/controllers/WriteOffsErpController.php @@ -933,8 +933,11 @@ class WriteOffsErpController extends Controller ->one(); - if (WriteOffsErp::isManager($model->store_id)) { - return 'У вас нет прав для согласования списаний!'; + + if (WriteOffsErp::isTestStore($model->store_id)) { + if (WriteOffsErp::isManager($model->store_id)) { + return 'У вас нет прав для согласования списаний!'; + } } /** @var WriteOffsErp $model */ diff --git a/erp24/records/WriteOffsErp.php b/erp24/records/WriteOffsErp.php index 4c8eae50..78dd45ac 100644 --- a/erp24/records/WriteOffsErp.php +++ b/erp24/records/WriteOffsErp.php @@ -133,6 +133,8 @@ class WriteOffsErp extends \yii\db\ActiveRecord self::STATUS_ERROR_1С => "Ошибка в 1С", ]; + public const TEST_STORES = [1, 9, 28, 30, 15, 44, 8]; + public function custom_function_validation($attribute, $params) { if(!in_array($this->$attribute, $params['values'])) { @@ -769,10 +771,15 @@ class WriteOffsErp extends \yii\db\ActiveRecord public static function isManager(int $storeId) : bool { $adminId = Yii::$app->user->id; - $isStoreOnNewSystem = (in_array($storeId, [1, 9, 28, 30, 15, 44, 8])); + $isStoreOnNewSystem = self::isTestStore($storeId); if (in_array($adminId, [785, 1463, 225, 1070, 826, 1036]) && $isStoreOnNewSystem ) { return false; } return true; } + + public static function isTestStore(int $storeId) : bool + { + return (in_array($storeId, self::TEST_STORES)); + } } diff --git a/erp24/views/write_offs_erp/view.php b/erp24/views/write_offs_erp/view.php index fec4a73b..7cc37b76 100644 --- a/erp24/views/write_offs_erp/view.php +++ b/erp24/views/write_offs_erp/view.php @@ -192,9 +192,13 @@ $this->registerCssFile('/css/write-offs-erp.css', ['position' => \yii\web\View:: store_id)) { - $class .= ' disabled'; + $title = ''; + $isTestStore = WriteOffsErp::isTestStore($model->store_id); + if ($isTestStore) { + if (WriteOffsErp::isManager($model->store_id)) { + $class .= ' disabled'; + $title = "Согласовать списания на данном магазине могут только Трушина Вера, Горячев Дмитрий, Цветкова Ольга, Яшенкова Алена и Емельянова Ольга"; + } } echo Html::tag('span', Html::button('Согласовать', [ @@ -224,7 +228,7 @@ $this->registerCssFile('/css/write-offs-erp.css', ['position' => \yii\web\View:: " ]), [ - 'title' => 'Согласовать списания на данном магазине могут только Трушина Вера, Горячев Дмитрий, Цветкова Ольга, Яшенкова Алена и Емельянова Ольга', + 'title' => $title, 'style' => 'display:inline-block; cursor: help;', ] );