]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Отчеты
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 29 Oct 2025 08:57:43 +0000 (11:57 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 29 Oct 2025 08:57:43 +0000 (11:57 +0300)
15 files changed:
erp24/actions/grade/AdminUpdateAction.php
erp24/api3/core/services/ReportService.php
erp24/migrations/m251027_071121_create_admin_positions_table.php [new file with mode: 0644]
erp24/migrations/m251027_071237_add_admin_position_id_field_to_admin_table.php [new file with mode: 0644]
erp24/migrations/m251028_141001_add_salary_and_group_id_fields_to_employee_position_table.php [new file with mode: 0644]
erp24/records/AdminGroup.php
erp24/records/EmployeePosition.php
erp24/records/EmployeePositionSearch.php
erp24/views/crud/employee-position/_form.php
erp24/views/crud/employee-position/_search.php
erp24/views/crud/employee-position/create.php
erp24/views/crud/employee-position/index.php
erp24/views/crud/employee-position/update.php
erp24/views/crud/employee-position/view.php
erp24/views/grade/admin-update.php

index c4db7f36b7454bff746cdf394e6223d84b5849ac..e81eefddfb0162c7fc6f67c15242f30699fffb73 100644 (file)
@@ -11,6 +11,7 @@ use yii_app\records\AdminGroup;
 use yii_app\records\AdminStores;
 use yii_app\records\CityStore;
 use yii_app\records\Companies;
+use yii_app\records\EmployeePosition;
 use yii_app\records\ExportImportTable;
 use yii_app\services\HistoryService;
 
@@ -74,6 +75,14 @@ class AdminUpdateAction extends Action
                     Yii::$app->cache->set("dirtyAuthSettings", true);
                 }
 
+                // Обновляем group_name на основе выбранной группы
+                if (isset($attributes['group_id'])) {
+                    $adminGroup = AdminGroup::findOne($attributes['group_id']);
+                    if ($adminGroup) {
+                        $attributes['group_name'] = $adminGroup->name;
+                    }
+                }
+
                 $model->setAttributes($attributes, false);
 
                 if (Yii::$app->user->can("manageAvatarka", ['id' => $model->id])) {
@@ -145,7 +154,7 @@ class AdminUpdateAction extends Action
         }
 
         $admins = ArrayHelper::map($adminArr, 'id', 'name', 'groupName');
-
+        $positions = EmployeePosition::find()->orderBy('posit')->all();
         $cityStores = ArrayHelper::map(CityStore::find()->select(['id', 'name'])->all(), 'id', 'name');
 
         $adminHistoryCategories = HistoryService::getHistoryAdmin($model->id);
@@ -153,6 +162,6 @@ class AdminUpdateAction extends Action
         $companies = ArrayHelper::map(Companies::find()->all(), 'id', 'name');
 
         return $this->controller->render('admin-update', compact('model', 'adminGroups', 'admins',
-            'cityStores', 'adminHistoryCategories', 'companies'));
+            'cityStores', 'adminHistoryCategories', 'companies', 'positions'));
     }
 }
index 096f6d4d635b1cca322a0c8a52100173e7612830..97f98620f3464077f7ad5a16b47d0995d185de15 100644 (file)
@@ -7,8 +7,10 @@ use yii\db\Exception;
 use yii\db\Expression;
 use yii\helpers\ArrayHelper;
 use yii_app\api3\modules\v1\models\timetable\Timetable;
+use yii_app\records\Admin;
 use yii_app\records\AdminPayrollDays;
 use yii_app\records\CityStore;
+use yii_app\records\EmployeePosition;
 use yii_app\records\ExportImportTable;
 use yii_app\records\Products1c;
 use yii_app\records\ProductsClass;
@@ -28,6 +30,7 @@ class ReportService
 
         $currentDate = $data->date_start;
         $reports = [];
+        $totalEmployeePositionsOnShift = [];
 
         $employees = Sales::find()->select(["COUNT(*) as cnt", "admin_id"])
             ->where([
@@ -39,11 +42,54 @@ class ReportService
             ->groupBy(['admin_id'])->asArray()->all();
         $employeeCount = count($employees);
 
+        // Получаем все уникальные admin_id сотрудников за период
+        $allAdminsInPeriod = Timetable::find()->alias('t')
+            ->select(['admin_id'])
+            ->distinct()
+            ->where(['t.store_id' => $data->stores])
+            ->andWhere(['>=', 'date', date("Y-m-01", strtotime($data->date_start))])
+            ->andWhere(['<=', 'date', $data->date_end])
+            ->andWhere(['tabel' => 0, 'slot_type_id' => Timetable::TIMESLOT_WORK])
+            ->asArray()->all();
+
+        $adminIdsInPeriod = ArrayHelper::getColumn($allAdminsInPeriod, 'admin_id');
+
+        $employeePositions = EmployeePosition::find()->select(['id', 'name'])->indexBy('id')->asArray()->all();
+
+        $adminPositions = Admin::find()->select(['id', 'employee_position_id', 'group_name'])
+            ->where(['id' => $adminIdsInPeriod])
+            ->indexBy('id')
+            ->asArray()->all();
+
+        // Создаем карту должностей для каждого admin_id
+        $positionMap = [];
+        foreach ($adminPositions as $adminId => $admin) {
+            $positionName = '';
+
+            if (!empty($admin['employee_position_id']) && isset($employeePositions[$admin['employee_position_id']])) {
+                $positionName = $employeePositions[$admin['employee_position_id']]['name'];
+            } elseif (!empty($admin['group_name'])) {
+                // Ищем похожее название в employee_positions
+                $groupNameLower = mb_strtolower(trim($admin['group_name']));
+                $found = false;
+                foreach ($employeePositions as $empPos) {
+                    if (mb_strpos($groupNameLower, mb_strtolower(trim($empPos['name']))) !== false ||
+                        mb_strpos(mb_strtolower(trim($empPos['name'])), $groupNameLower) !== false) {
+                        $positionName = $empPos['name'];
+                        $found = true;
+                        break;
+                    }
+                }
+                if (!$found) {
+                    $positionName = $admin['group_name'];
+                }
+            }
+
+            $positionMap[$adminId] = $positionName;
+        }
+
         while ($currentDate <= $data->date_end) {
-            $report = [
-                "date" => $currentDate,
-                "shift_type" => $data->shift_type,
-            ];
+            $report = [];
 
             $shift_id = $data->shift_type == 0 ? [1, 2, 5, 8] : ($data->shift_type == 1 ? [1, 5, 8] : [2]);
 
@@ -65,6 +111,26 @@ class ReportService
             $adminIdsMonth = ArrayHelper::getColumn($timetablesMonth, 'admin_id');
             $adminIds = ArrayHelper::getColumn($timetables, 'admin_id');
 
+            // Подсчет должностей на смене для этого дня
+            $employeePositionsOnShift = [];
+            foreach ($timetables as $timetable) {
+                $adminId = $timetable['admin_id'];
+                $positionName = $positionMap[$adminId] ?? '';
+
+                if (!empty($positionName)) {
+                    if (!isset($employeePositionsOnShift[$positionName])) {
+                        $employeePositionsOnShift[$positionName] = 0;
+                    }
+                    $employeePositionsOnShift[$positionName]++;
+
+                    // Суммируем для общего отчета
+                    if (!isset($totalEmployeePositionsOnShift[$positionName])) {
+                        $totalEmployeePositionsOnShift[$positionName] = 0;
+                    }
+                    $totalEmployeePositionsOnShift[$positionName]++;
+                }
+            }
+
             $adminPayrollDaysMonth = AdminPayrollDays::find()->select(["FLOOR(SUM(day_payroll)) as total", "store_id"])
                 ->where(['>=', 'date', date("Y-m-01", strtotime($currentDate))])
                 ->andWhere(['<=', 'date', $currentDate])
@@ -360,11 +426,27 @@ class ReportService
                 $totalServicePerDayTotal += $totalServicePerDay;
                 $totalPottedPerDayTotal += $totalPottedPerDay;
 
+                // Подсчет должностей для этого магазина
+                $storeEmployeePositionsOnShift = [];
+                if (isset($adminNames[$store->id])) {
+                    foreach ($adminNames[$store->id] as $adminRecord) {
+                        $adminId = $adminRecord['id'];
+                        $positionName = $positionMap[$adminId] ?? '';
+
+                        if (!empty($positionName)) {
+                            if (!isset($storeEmployeePositionsOnShift[$positionName])) {
+                                $storeEmployeePositionsOnShift[$positionName] = 0;
+                            }
+                            $storeEmployeePositionsOnShift[$positionName]++;
+                        }
+                    }
+                }
 
                 $reportStore = [
                     "name" => $store->name,
                     "id" => $store->id,
                     "admins" => $adminNames[$store->id] ?? [],
+                    "employee_positions_on_shift" => $storeEmployeePositionsOnShift,
                     "visitors_quantity" => $storeVisitorsQuantity,
                     "sale_quantity" => $storeSaleQuantity,
                     "sale_total" => $storeSaleTotal,
@@ -415,9 +497,18 @@ class ReportService
                 "total_wrap_per_day" => $totalWrapPerDayTotal,
                 "total_services_per_day" => $totalServicePerDayTotal,
                 "total_potted_per_day" => $totalPottedPerDayTotal,
+                "employee_positions_on_shift" => $employeePositionsOnShift,
+            ];
+
+            // Создаем итоговый массив для дня с правильным порядком полей
+            $dayReport = [
+                "date" => $currentDate,
+                "shift_type" => $data->shift_type,
+                "stores" => $report["stores"] ?? [],
+                "total" => $report['total'],
             ];
 
-            $reports[] = $report;
+            $reports[] = $dayReport;
             $currentDate = date("Y-m-d", strtotime("+1 day", strtotime($currentDate)));
         }
 
diff --git a/erp24/migrations/m251027_071121_create_admin_positions_table.php b/erp24/migrations/m251027_071121_create_admin_positions_table.php
new file mode 100644 (file)
index 0000000..c805a67
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%admin_positions}}`.
+ */
+class m251027_071121_create_admin_positions_table extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    const TABLE_NAME = 'erp24.admin_positions';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (!isset($tableSchema)) {
+            $this->createTable(self::TABLE_NAME, [
+                'id' => $this->primaryKey(),
+                'name' => $this->string()->notNull()->comment('Наименование должности'),
+                'alias' => $this->string()->notNull()->comment('Алиас должности'),
+                'salary' => $this->decimal(10, 2)->notNull()->comment('Ставка в рублях'),
+                'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
+                'created_by' => $this->integer()->notNull()->comment('ИД создателя'),
+                'updated_at' => $this->dateTime()->null()->comment('Дата обновления'),
+                'updated_by' => $this->integer()->null()->comment('ИД редактировавшего'),
+            ]);
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->dropTable('{{%admin_positions}}');
+    }
+}
diff --git a/erp24/migrations/m251027_071237_add_admin_position_id_field_to_admin_table.php b/erp24/migrations/m251027_071237_add_admin_position_id_field_to_admin_table.php
new file mode 100644 (file)
index 0000000..367c7e1
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+use yii\db\Migration;
+
+class m251027_071237_add_admin_position_id_field_to_admin_table extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    const TABLE_NAME = 'erp24.admin';
+    const COLUMN_NAME = 'employee_position_id';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (isset($tableSchema) && !isset($tableSchema->columns[self::COLUMN_NAME])) {
+            $this->addColumn(self::TABLE_NAME, self::COLUMN_NAME, $this->integer()->null()->comment('ID должности администратора'));
+            $this->addForeignKey(
+                'fk-admin-employee_position_id',
+                self::TABLE_NAME,
+                self::COLUMN_NAME,
+                'erp24.employee_position',
+                'id',
+                'SET NULL',
+                'CASCADE'
+            );
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (isset($tableSchema) && isset($tableSchema->columns[self::COLUMN_NAME])) {
+            $this->dropForeignKey('fk-admin-employee_position_id', self::TABLE_NAME);
+            $this->dropColumn(self::TABLE_NAME, self::COLUMN_NAME);
+        } else {
+            echo "m251027_071237_add_admin_position_id_field_to_admin_table cannot be reverted.\n";
+            return false;
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m251027_071237_add_admin_position_id_field_to_admin_table cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
diff --git a/erp24/migrations/m251028_141001_add_salary_and_group_id_fields_to_employee_position_table.php b/erp24/migrations/m251028_141001_add_salary_and_group_id_fields_to_employee_position_table.php
new file mode 100644 (file)
index 0000000..c616df3
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+
+use yii\db\Migration;
+
+class m251028_141001_add_salary_and_group_id_fields_to_employee_position_table extends Migration
+{
+    const TABLE_NAME = 'erp24.employee_position';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        // Добавляем поле salary
+        if (isset($tableSchema) && !isset($tableSchema->columns['salary'])) {
+            $this->addColumn(self::TABLE_NAME, 'salary', $this->integer()->null()->comment('Зарплата'));
+        }
+
+        // Добавляем поле alias
+        if (isset($tableSchema) && !isset($tableSchema->columns['alias'])) {
+            $this->addColumn(self::TABLE_NAME, 'alias', $this->string(255)->null()->comment('Алиас'));
+        }
+
+        // Добавляем поле group_id
+        if (isset($tableSchema) && !isset($tableSchema->columns['group_id'])) {
+            $this->addColumn(self::TABLE_NAME, 'group_id', $this->integer()->null()->comment('Ссылка на группу'));
+            $this->addForeignKey(
+                'fk-employee_position-group_id',
+                self::TABLE_NAME,
+                'group_id',
+                'erp24.admin_group',
+                'id',
+                'SET NULL',
+                'CASCADE'
+            );
+        }
+
+        // Добавляем поле created_by
+        if (isset($tableSchema) && !isset($tableSchema->columns['created_by'])) {
+            $this->addColumn(self::TABLE_NAME, 'created_by', $this->integer()->null()->comment('Кем создано'));
+        }
+
+        // Добавляем поле updated_by
+        if (isset($tableSchema) && !isset($tableSchema->columns['updated_by'])) {
+            $this->addColumn(self::TABLE_NAME, 'updated_by', $this->integer()->null()->comment('Кем изменено'));
+        }
+
+        // Добавляем поле created_at
+        if (isset($tableSchema) && !isset($tableSchema->columns['created_at'])) {
+            $this->addColumn(self::TABLE_NAME, 'created_at', $this->timestamp()->null()->comment('Дата создания'));
+        }
+
+        // Добавляем поле updated_at
+        if (isset($tableSchema) && !isset($tableSchema->columns['updated_at'])) {
+            $this->addColumn(self::TABLE_NAME, 'updated_at', $this->timestamp()->null()->comment('Дата изменения'));
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        // Удаляем поле updated_by
+        if (isset($tableSchema) && isset($tableSchema->columns['updated_by'])) {
+            $this->dropColumn(self::TABLE_NAME, 'updated_by');
+        }
+
+        // Удаляем поле created_by
+        if (isset($tableSchema) && isset($tableSchema->columns['created_by'])) {
+            $this->dropColumn(self::TABLE_NAME, 'created_by');
+        }
+
+        // Удаляем поле group_id
+        if (isset($tableSchema) && isset($tableSchema->columns['group_id'])) {
+            $this->dropForeignKey('fk-employee_position-group_id', self::TABLE_NAME);
+            $this->dropColumn(self::TABLE_NAME, 'group_id');
+        }
+
+        // Удаляем поле alias
+        if (isset($tableSchema) && isset($tableSchema->columns['alias'])) {
+            $this->dropColumn(self::TABLE_NAME, 'alias');
+        }
+
+        // Удаляем поле updated_at
+        if (isset($tableSchema) && isset($tableSchema->columns['updated_at'])) {
+            $this->dropColumn(self::TABLE_NAME, 'updated_at');
+        }
+
+        // Удаляем поле created_at
+        if (isset($tableSchema) && isset($tableSchema->columns['created_at'])) {
+            $this->dropColumn(self::TABLE_NAME, 'created_at');
+        }
+
+        // Удаляем поле salary
+        if (isset($tableSchema) && isset($tableSchema->columns['salary'])) {
+            $this->dropColumn(self::TABLE_NAME, 'salary');
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m251028_141001_add_salary_and_group_id_fields_to_employee_position_table cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
index cdce32c666a10f3a6637220c794d1fa5fd0ab557..5a53070a43531f6a33737a6e8df936dde2e49bf6 100755 (executable)
@@ -4,6 +4,7 @@ declare(strict_types = 1);
 namespace yii_app\records;
 
 use yii\db\ActiveRecord;
+use yii\helpers\ArrayHelper;
 
 /**
  * Class AdminGroup
@@ -189,4 +190,17 @@ class AdminGroup extends ActiveRecord
     {
         return in_array($this->id, [7, Admin::ADMINISTRATOR_GROUP_ID]);
     }
+
+    public static function getAllIdName()
+    {
+        $result = [];
+
+        $values = self::find()->all();
+
+        if(!empty($values)){
+            $result = ArrayHelper::map($values, 'id', 'name');
+        }
+
+        return $result;
+    }
 }
\ No newline at end of file
index 5b24e83e082333b360a79d1ebcd1dc2ab32c9bf0..31d47c2887e7d03139214cd0fa9d312e3f342913 100755 (executable)
@@ -4,6 +4,8 @@ namespace yii_app\records;
 
 use Yii;
 use yii\helpers\ArrayHelper;
+use yii\behaviors\TimestampBehavior;
+use yii\behaviors\BlameableBehavior;
 
 /**
  * This is the model class for table "employee_position".
@@ -12,6 +14,13 @@ use yii\helpers\ArrayHelper;
  * @property string $name
  * @property int $next_position_id
  * @property int $posit
+ * @property int $salary
+ * @property string $alias
+ * @property int $group_id
+ * @property string $created_at
+ * @property int $created_by
+ * @property string $updated_at
+ * @property int $updated_by
  */
 class EmployeePosition extends \yii\db\ActiveRecord
 {
@@ -23,6 +32,28 @@ class EmployeePosition extends \yii\db\ActiveRecord
         return 'employee_position';
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'createdAtAttribute' => 'created_at',
+                'updatedAtAttribute' => 'updated_at',
+                'value' => function () {
+                    return date('Y-m-d H:i:s');
+                },
+            ],
+            [
+                'class' => BlameableBehavior::class,
+                'createdByAttribute' => 'created_by',
+                'updatedByAttribute' => 'updated_by',
+            ],
+        ];
+    }
+
     /**
      * {@inheritdoc}
      */
@@ -30,8 +61,10 @@ class EmployeePosition extends \yii\db\ActiveRecord
     {
         return [
             [['name'], 'required'],
-            [['name'], 'string', 'max' => 45],
-            [['next_position_id', 'posit'], 'safe'],
+            [['name', 'alias'], 'string', 'max' => 255],
+            [['next_position_id', 'posit', 'salary', 'group_id', 'created_by', 'updated_by'], 'integer'],
+            [['created_at', 'updated_at'], 'safe'],
+            [['salary', 'alias', 'group_id', 'created_at', 'created_by', 'updated_at', 'updated_by'], 'default', 'value' => null],
         ];
     }
 
@@ -42,9 +75,16 @@ class EmployeePosition extends \yii\db\ActiveRecord
     {
         return [
             'id' => 'ID',
-            'name' => 'Name',
-            'next_position_id' => 'Next Position Id',
-            'posit' => 'Posit',
+            'name' => 'Название',
+            'next_position_id' => 'Следующая должность',
+            'posit' => 'Позиция',
+            'salary' => 'Зарплата',
+            'alias' => 'Алиас',
+            'group_id' => 'Группа',
+            'created_at' => 'Дата создания',
+            'created_by' => 'Кем создано',
+            'updated_at' => 'Дата изменения',
+            'updated_by' => 'Кем изменено',
         ];
     }
 
@@ -68,4 +108,8 @@ class EmployeePosition extends \yii\db\ActiveRecord
     public function getSkills() {
         return $this->hasMany(EmployeeSkill::class, ['id' => 'skill_id'])->via('positionSkill');
     }
+
+    public function getAdminGroup() {
+        return $this->hasOne(\yii_app\records\AdminGroup::class, ['id' => 'group_id']);
+    }
 }
index c9cc96b6fa2e526b41ecba0169e90323da7cb357..5071f74d6eba48b96ae0778f11b17f198f5e63c4 100755 (executable)
@@ -9,16 +9,22 @@ use yii_app\records\EmployeePosition;
 /**
  * EmployeePositionSearch represents the model behind the search form of `yii_app\records\EmployeePosition`.
  */
-class EmployeePositionSearch extends EmployeePosition
+class EmployeePositionSearch extends Model
 {
+    public $id;
+    public $name;
+    public $alias;
+    public $salary;
+    public $group_id;
+
     /**
      * {@inheritdoc}
      */
     public function rules()
     {
         return [
-            [['id'], 'integer'],
-            [['name'], 'safe'],
+            [['id', 'salary', 'group_id'], 'integer'],
+            [['name', 'alias'], 'safe'],
         ];
     }
 
@@ -59,9 +65,12 @@ class EmployeePositionSearch extends EmployeePosition
         // grid filtering conditions
         $query->andFilterWhere([
             'id' => $this->id,
+            'salary' => $this->salary,
+            'group_id' => $this->group_id,
         ]);
 
-        $query->andFilterWhere(['like', 'name', $this->name]);
+        $query->andFilterWhere(['like', 'name', $this->name])
+            ->andFilterWhere(['like', 'alias', $this->alias]);
 
         return $dataProvider;
     }
index eccf21fd7718757b5ace05e44966a930085281f7..680dd3d15f7ba76454465096bd6fb009c129a682 100755 (executable)
@@ -23,6 +23,12 @@ function printBlock($title, $block) {
 
     <?php printBlock('Название', $form->field($model, 'name')->textInput(['maxlength' => true])->label(false)) ?>
 
+    <?php printBlock('Алиас', $form->field($model, 'alias')->textInput(['maxlength' => true])->label(false)) ?>
+
+    <?php printBlock('Зарплата', $form->field($model, 'salary')->textInput(['type' => 'number'])->label(false)) ?>
+
+    <?php printBlock('Группа', $form->field($model, 'group_id')->dropDownList(\yii_app\records\AdminGroup::getAllIdName(), ['prompt' => 'Выберите группу'])->label(false)) ?>
+
     <?php printBlock('Позиция', $form->field($model, 'posit')->textInput(['maxlength' => true])->label(false)) ?>
 
     <div class="form-group">
index ecfb9ab1f24dc738bd1597b0526d725df7d11e87..d6ef204e9bc2998f13ef51082333efc16c9b890d 100755 (executable)
@@ -19,6 +19,12 @@ use yii\widgets\ActiveForm;
 
     <?= $form->field($model, 'name') ?>
 
+    <?= $form->field($model, 'alias') ?>
+
+    <?= $form->field($model, 'salary') ?>
+
+    <?= $form->field($model, 'group_id')->dropDownList(\yii_app\records\AdminGroup::getAllIdName(), ['prompt' => 'Все группы']) ?>
+
     <div class="form-group">
         <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
         <?= Html::resetButton('Reset', ['class' => 'btn btn-outline-secondary']) ?>
index b980eed37e415b3fe7b9072412610fe2c5143805..2c14c8b40d72db938853f0964256250dfa00dcf5 100755 (executable)
@@ -9,7 +9,7 @@ $this->title = 'Создать позицию работника';
 $this->params['breadcrumbs'][] = ['label' => 'Employee Positions', 'url' => ['index']];
 $this->params['breadcrumbs'][] = $this->title;
 ?>
-<div class="employee-position-create">
+<div class="employee-position-create p-4">
 
     <h1><?= Html::encode($this->title) ?></h1>
 
index 5b8870289467852622290a64294302134e1887e9..a6679d04cb7985b5ee1b839345e4413b97586d95 100755 (executable)
@@ -13,7 +13,7 @@ use yii\grid\GridView;
 $this->title = 'Позиции работников';
 $this->params['breadcrumbs'][] = $this->title;
 ?>
-<div class="employee-position-index">
+<div class="employee-position-index p-4">
 
     <h1><?= Html::encode($this->title) ?></h1>
 
@@ -21,7 +21,7 @@ $this->params['breadcrumbs'][] = $this->title;
         <?= Html::a('Создать позицию работника', ['create'], ['class' => 'btn btn-success']) ?>
     </p>
 
-    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
+    <?php //echo $this->render('_search', ['model' => $searchModel]); ?>
 
     <?= GridView::widget([
         'dataProvider' => $dataProvider,
@@ -37,6 +37,14 @@ $this->params['breadcrumbs'][] = $this->title;
                     return Html::a($model->name, ['/crud/employee-position/update', 'id' => $model->id], ['class' => 'btn btn-link']);
                 }
             ],
+            'alias',
+            'salary',
+            [
+                'attribute' => 'group_id',
+                'value' => function ($model) {
+                    return $model->adminGroup ? $model->adminGroup->name : null;
+                }
+            ],
             [
                 'class' => ActionColumn::className(),
                 'urlCreator' => function ($action, EmployeePosition $model, $key, $index, $column) {
index e33ca527e7fa9c12135ca68ea92251dc2dcfff07..5e2183d7126ea2e9c6e6448bf91457b333e5850f 100755 (executable)
@@ -10,7 +10,7 @@ $this->params['breadcrumbs'][] = ['label' => 'Employee Positions', 'url' => ['in
 $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
 $this->params['breadcrumbs'][] = 'Update';
 ?>
-<div class="employee-position-update">
+<div class="employee-position-update p-4">
 
     <small>Редактирование регламента: </small>
     <h3><a href="<?= \yii\helpers\Url::to(['/crud/employee-position']) ?>" class="btn btn-primary m-2">Назад</a>
index 635d6529e03133961697df6c0a32d0766a65c5fc..0e49380482547eaf729432bed571f28d8ee45dfa 100644 (file)
@@ -18,7 +18,7 @@ $this->params['breadcrumbs'][] = $this->title;
     </div>
 </div>
 
-<div class="employee-position-view">
+<div class="employee-position-view p-4">
 
     <h1><?= Html::encode($this->title) ?></h1>
 
@@ -38,6 +38,28 @@ $this->params['breadcrumbs'][] = $this->title;
         'attributes' => [
             'id',
             'name',
+            'alias',
+            'salary',
+            [
+                'attribute' => 'group_id',
+                'value' => function ($model) {
+                    return $model->adminGroup ? $model->adminGroup->name : null;
+                }
+            ],
+            'created_at',
+            [
+                'attribute' => 'created_by',
+                'value' => function ($model) {
+                    return $model->created_by ? \yii_app\records\Admin::findOne($model->created_by)->name ?? 'Неизвестен' : null;
+                }
+            ],
+            'updated_at',
+            [
+                'attribute' => 'updated_by',
+                'value' => function ($model) {
+                    return $model->updated_by ? \yii_app\records\Admin::findOne($model->updated_by)->name ?? 'Неизвестен' : null;
+                }
+            ],
         ],
     ]) ?>
 
index afd4561d66f400d45901a6b7528f418e9cbf69a4..9ad62f9eb08f0b8702bece7d10eca49acfbdaa62 100644 (file)
@@ -5,6 +5,7 @@ use dosamigos\datetimepicker\DateTimePicker;
 
 use yii\widgets\ActiveForm;
 use yii\helpers\Html;
+use yii\helpers\ArrayHelper;
 use yii_app\helpers\PrintBlockHelper;
 use yii_app\records\Admin;
 use yii_app\records\Products1c;
@@ -47,7 +48,9 @@ use yii_app\services\FileService;
     }
     ?>
 
-    <?php PrintBlockHelper::printBlock('Должность', $form->field($model, 'group_name')->textInput(['maxlength' => true])->label(false)) ?>
+    <?php PrintBlockHelper::printBlock('Должность', $form->field($model, 'employee_position_id')->dropDownList(
+        ArrayHelper::map($positions, 'id', 'name'), ['prompt' => 'Выберите должность']
+    )->label(false)) ?>
 
     <div id="workRate" style="display: <?= $model->group_id == \yii_app\records\AdminGroup::GROUP_ADMINISTRATORS ? 'block' : 'none'?>">
         <?php PrintBlockHelper::printBlock('Рабочий график', $form->field($model, 'work_rate')->dropDownList([1 => '5/2', 2 => '2/2', 3 => '3/3'])->label(false)) ?>