]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Исправление ошибки блокировки кнопки списания feature_filippov_20250612_write_offs_button_fix origin/feature_filippov_20250612_write_offs_button_fix
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Thu, 12 Jun 2025 20:49:41 +0000 (23:49 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Thu, 12 Jun 2025 20:49:41 +0000 (23:49 +0300)
erp24/controllers/WriteOffsErpController.php
erp24/records/WriteOffsErp.php
erp24/views/write_offs_erp/view.php

index c2d03a2b1d3f5c2fbf9c0fa38a7533be4598e2e1..b7a4dc44fdf12bbdcebc9b9589989fc3ef8b52dc 100644 (file)
@@ -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 */
index 4c8eae505004a09c660bed31e036250ab8a0cc35..78dd45ac4183f2a8350f682a148461dfb15ff5dc 100644 (file)
@@ -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));
+    }
 }
index fec4a73bc82613822e74635ef7eb826b5f7a0e7e..7cc37b76b2da7cf1280574f6e7b2c08a6ecf16d1 100644 (file)
@@ -192,9 +192,13 @@ $this->registerCssFile('/css/write-offs-erp.css', ['position' => \yii\web\View::
 
                 <?php
                 $class = 'btn btn-success btn-lg';
-
-                if (WriteOffsErp::isManager($model->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;',
                     ]
                 );