]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-5 Доработать фактический план по сотрудникам
authormarina <m.zozirova@gmail.com>
Wed, 12 Jun 2024 22:46:11 +0000 (01:46 +0300)
committermarina <m.zozirova@gmail.com>
Wed, 12 Jun 2024 22:46:11 +0000 (01:46 +0300)
erp24/records/AdminCheckin.php
erp24/records/TimetableFactModel.php
erp24/views/timetable-fact/index.php
erp24/views/timetable-fact/view.php [new file with mode: 0644]

index d7ee4df856ce4d3126693fd468245e77c1d1bc47..8f11e0fe3b770ba3cd7f236c802714d83c406509 100755 (executable)
@@ -64,6 +64,15 @@ class AdminCheckin extends ActiveRecord
         ];
     }
 
+    public static function getStatus($code) {
+        $checkinType = [
+            self::TYPE_START => 'Открытие смены',
+            self::TYPE_END => 'Закрытие смены',
+            self::TYPE_APPEAR => 'Появление',
+        ];
+        return isset($checkinType[$code]) ? $checkinType[$code] : null;
+    }
+
     public function getRating()
     {
         return StartForm::ratings()[$this->ball] ?? $this->ball;
index 457d7e72ba6ce09a9bb94dbc73eaf4a8de72f555..8c4803095e69aad36f12f66f1d02718e2b439252 100644 (file)
@@ -53,6 +53,37 @@ class TimetableFactModel extends ActiveRecord
         return 'timetable_fact';
     }
 
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'admin_id' => 'Сотрудник',
+            'store_id' => 'Магазин',
+            'admin_group_id' => 'Должность',
+            'd_id' => 'в какой должности работал на смене',
+            'date_shift' => 'дата смены',
+            'date_start' => 'дата открытия смены',
+            'date_end' => 'дата закрытия смены',
+            'is_opening' => 'смена открыта?',
+            'is_close' => 'смена закрыта?',
+            'tabel' => 'табель',
+            'plan_id' => 'Табель, если смена поставлена',
+            'shift_id' => 'тип смены',
+            'admin_id_add' => 'Постановщик смены',
+            'time_start' => 'время начала работы по графику',
+            'time_end' => 'время окончания работы по графику',
+            'work_time' => 'отработано часов',
+            'price_hour' => 'часовая ставка',
+            'salary_shift' => 'оплата за смену',
+            'slot_type_id' => 'тип занятности',
+            'comment' => 'комментарий',
+            'date_add' => 'дата постановки смены',
+            'status' => 'статус смены',
+            'checkin_start_id' => 'Отметка о начале работы',
+            'checkin_end_id' => 'Отметки об окончании работы'
+        ];
+    }
+
     public function rules()
     {
         return [
@@ -66,7 +97,7 @@ class TimetableFactModel extends ActiveRecord
             [['comment'], 'default', 'value' => null],
             [['slot_type_id', 'date_add', 'date_end', 'time_end', 'salary_shift', 'price_hour'], 'safe'],
             [['date_shift'], 'date', 'format' => 'yyyy-M-d'],
-            [['time_start',  'shift_id'], 'required'],
+            [['time_start', 'shift_id'], 'required'],
         ];
     }
 
@@ -122,10 +153,11 @@ class TimetableFactModel extends ActiveRecord
             $model->price_hour = $model->salary_shift / ($model->d_id == AdminGroup::GROUP_ADMINISTRATORS ? 8 : 12);
         }
 
-        if($model->validate()) {
+        if ($model->validate()) {
             $model->save();
         } else {
-            var_dump($model->getErrors());die();
+            var_dump($model->getErrors());
+            die();
         }
     }
 
@@ -135,15 +167,16 @@ class TimetableFactModel extends ActiveRecord
         return $this->hasOne(Admin::class, ['id' => 'admin_id']);
     }
 
-       public function getCheckinStart()
-{
-    return $this->hasOne(AdminCheckin::class, ['id' => 'checkin_start_id']);
-}
+    public function getCheckinStart()
+    {
+        return $this->hasOne(AdminCheckin::class, ['id' => 'checkin_start_id']);
+    }
 
     public function getCheckinEnd()
     {
         return $this->hasOne(AdminCheckin::class, ['id' => 'checkin_end_id']);
     }
+
     public function getShift()
     {
         return $this->hasOne(Shift::class, ['id' => 'shift_id']);
index 261217337457f0047edf0b66b620b0f6933d9975..1b27b8258186a34de4f3a8672b05ea1616adc57f 100644 (file)
@@ -86,6 +86,10 @@ $this->params['breadcrumbs'][] = $this->title;
                     return !empty($model->checkinEnd->photo) ? Html::img($model->checkinEnd->photo, ['alt="selfie" height="100px"']) : '';
                 },
             ],
+            [
+                'class' => ActionColumn::className(),
+                'template' => '{view}',
+            ],
         ],
     ]); ?>
 
diff --git a/erp24/views/timetable-fact/view.php b/erp24/views/timetable-fact/view.php
new file mode 100644 (file)
index 0000000..89fcd2d
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+use yii_app\records\AdminCheckin;
+
+/** @var yii\web\View $this */
+/** @var app\records\TimetableFactModel $model */
+
+$this->title = "Фактический табель #$model->id";
+
+\yii\web\YiiAsset::register($this);
+?>
+<div class="timetable-fact-model-view">
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+    <p>
+<!--        --><?php //= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+<!--        --><?php //= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
+//            'class' => 'btn btn-danger',
+//            'data' => [
+//                'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
+//                'method' => 'post',
+//            ],
+//        ]) ?>
+    </p>
+
+    <?= DetailView::widget([
+        'model' => $model,
+        'attributes' => [
+            'id',
+            [
+                'attribute' => 'admin_id',
+                'label' => 'Пользователь',
+                'value' => function ($data) {
+                    return $data->admin->name;
+                }
+            ],
+            [
+                'attribute' => 'store_id',
+                'label' => 'Магазин',
+                'value' => function ($data) {
+                    return $data->store->name;
+                }
+            ],
+            [
+                'attribute' => 'admin_group_id',
+                'value' => function ($data) {
+                    return $data->adminGroup->name;
+                }
+            ],
+            [
+                'attribute' => 'd_id',
+                'value' => function ($data) {
+                    return $data->d->name;
+                }
+            ],
+            [
+                'attribute' => 'date_shift',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return Yii::$app->formatter->asDatetime($model->date_shift, 'php:d.m.Y');
+                },
+            ],
+            [
+                'attribute' => 'date_start',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return Yii::$app->formatter->asDatetime($model->date_start, 'php:d.m.Y');
+                },
+            ],
+            [
+                'attribute' => 'date_end',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return Yii::$app->formatter->asDatetime($model->date_end, 'php:d.m.Y');
+                },
+            ],
+            [
+                'attribute' => 'time_start',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return Yii::$app->formatter->asDatetime($model->time_start, 'php:H:i:s');
+                },
+            ],
+            [
+                'attribute' => 'time_end',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return Yii::$app->formatter->asDatetime($model->time_end, 'php:H:i:s');
+                },
+            ],
+            'work_time',
+            [
+                'attribute' => 'is_opening',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return $model->is_opening ? 'Да' : 'Нет';
+                },
+            ],
+            [
+                'attribute' => 'is_close',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return $model->is_close ? 'Да' : 'Нет';
+                },
+            ],
+            [
+                'attribute' => 'status',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return AdminCheckin::getStatus($model->status);
+                },
+            ],
+            'tabel',
+//            'plan_id',
+            [
+                'attribute' => 'admin_group_id',
+                'value' => function ($data) {
+                    return $data->shift->name;
+                }
+            ],
+            [
+                'attribute' => 'admin_id_add',
+                'value' => function ($data) {
+                    return $data->adminAdd->name;
+                }
+            ],
+            'price_hour',
+            'salary_shift',
+            'slot_type_id',
+            'comment:ntext',
+            [
+                'attribute' => 'date_add',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return Yii::$app->formatter->asDatetime($model->date_add, 'php:H:i:s d.m.Y');
+                },
+            ],
+            [
+                'label' => 'Отметка о начале',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return !empty($model->checkinStart->photo) ? Html::img($model->checkinStart->photo, ['alt="selfie" height="100px"']) : '';
+                },
+            ],
+            [
+                'label' => 'Отметка о конце',
+                'format' => 'raw',
+                'value' => function ($model) {
+                    return !empty($model->checkinEnd->photo) ? Html::img($model->checkinEnd->photo, ['alt="selfie" height="100px"']) : '';
+                },
+            ],
+        ],
+    ]) ?>
+
+</div>