]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
fix set actual code
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 15 Mar 2024 11:15:38 +0000 (14:15 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 15 Mar 2024 11:15:38 +0000 (14:15 +0300)
erp24/records/Admin.php

index 98cc247682f2894b89aa78e9ca7b4d565db0ca74..9c04ccf95f53cd64e3426bc5de058c7da2ae6c89 100755 (executable)
@@ -10,6 +10,7 @@ use yii\db\ActiveRecord;
 use yii\db\Expression;
 use yii\helpers\ArrayHelper;
 use yii\web\IdentityInterface;
+use yii_app\api3\core\validators\PhoneValidator;
 
 /**
  * Class Admin
@@ -34,6 +35,8 @@ class Admin extends ActiveRecord implements IdentityInterface
 
     public $phone;
 
+    const SHIFT_HOUR_COUNT_ADMINISTRATOR = 8;
+    const SHIFT_HOUR_COUNT_FLORIST = 12;
     const WORK_STATUS_IS_WORK = 1;
     const WORK_STATUS_FIRED = 4;
 
@@ -52,6 +55,16 @@ class Admin extends ActiveRecord implements IdentityInterface
         self::PART_TIME_WORKER_GROUP_ID, // Подработчики
         -1
     ];
+    const ADMIN_PAYROLL_MAKE_GROUP_IDS = [
+        30,
+        35,
+        40,
+        self::PART_TIME_WORKER_GROUP_ID, // Подработчики
+        self::ADMINISTRATOR_GROUP_ID, // Администраторы
+        72, //
+        90, // Подработчики (архив)
+        -1,
+    ];
 
     const ADMIN_WRITE_OFFS_SINGLE_STORE_GROUP_IDS = [
         30,
@@ -61,6 +74,13 @@ class Admin extends ActiveRecord implements IdentityInterface
         self::PART_TIME_WORKER_GROUP_ID, // Подработчики
         -1
     ];
+    const ADMIN_WORK_GROUP_IDS = [
+        30,
+        35,
+        40,
+        self::ADMINISTRATOR_GROUP_ID, // Администраторы
+        72, //
+    ];
 
     public $imageFile;
 
@@ -69,7 +89,7 @@ class Admin extends ActiveRecord implements IdentityInterface
 
     public static function tableName()
     {
-        return '{{%admin}}';
+        return 'admin';
     }
 
     public function rules()
@@ -91,6 +111,7 @@ class Admin extends ActiveRecord implements IdentityInterface
             [['group_name', 'pass_user', 'grazhdanstvo', 'passport_seriya'], 'string', 'max' => 120],
             [['login_user'], 'string', 'max' => 29],
             [['mobile', 'photo', 'snils'], 'string', 'max' => 25],
+            ['mobile', PhoneValidator::class],
             [['description', 'adress_fakt'], 'string', 'max' => 255],
             [['avatarka'], 'string', 'max' => 125],
             [['passport_nomer'], 'string', 'max' => 12],
@@ -372,6 +393,23 @@ class Admin extends ActiveRecord implements IdentityInterface
             ->column();
     }
 
+    public static function getAdminGuidNames(): array
+    {
+        $groupIds = Admin::ADMIN_CABINET_GROUP_IDS;
+        $notInStoreIds = Admin::NOT_IN_STORE_IDS;
+
+        $adminFloristPrepared = Admin::getAdmins('', $groupIds, 'ASC', null, '', $notInStoreIds, true);
+
+        $adminGuidNames = [];
+        foreach ($adminFloristPrepared as $key => $row) {
+            if (!empty($row['exportImportTable'])) {
+                $adminGuidNames[$row['exportImportTable']['export_val']] = $row['name'];
+            }
+        }
+
+        return $adminGuidNames;
+    }
+
     /**
      * @param $ids
      * @param $groupId
@@ -441,10 +479,10 @@ class Admin extends ActiveRecord implements IdentityInterface
             } elseif ($orderByName == 'DESC') {
                 $query->orderBy([self::tableName() . '.name_full' => SORT_DESC]);
             }
+        } else {
+            $query->orderBy([self::tableName() . '.store_id' => SORT_ASC]);
         }
 
-        $query->orderBy([self::tableName() . '.store_id' => SORT_ASC]);
-
         $action = $query->createCommand()->getRawSql();
 
         return $query->asArray()->all();