From: marina Date: Wed, 12 Jun 2024 22:46:11 +0000 (+0300) Subject: ERP-5 Доработать фактический план по сотрудникам X-Git-Tag: 1.2^2~4^2~8 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=09e932dfb2f63d2f8c8d8bf924a0374418d58a34;p=erp24_rep%2Fyii-erp24%2F.git ERP-5 Доработать фактический план по сотрудникам --- diff --git a/erp24/records/AdminCheckin.php b/erp24/records/AdminCheckin.php index d7ee4df8..8f11e0fe 100755 --- a/erp24/records/AdminCheckin.php +++ b/erp24/records/AdminCheckin.php @@ -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; diff --git a/erp24/records/TimetableFactModel.php b/erp24/records/TimetableFactModel.php index 457d7e72..8c480309 100644 --- a/erp24/records/TimetableFactModel.php +++ b/erp24/records/TimetableFactModel.php @@ -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']); diff --git a/erp24/views/timetable-fact/index.php b/erp24/views/timetable-fact/index.php index 26121733..1b27b825 100644 --- a/erp24/views/timetable-fact/index.php +++ b/erp24/views/timetable-fact/index.php @@ -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 index 00000000..89fcd2d2 --- /dev/null +++ b/erp24/views/timetable-fact/view.php @@ -0,0 +1,158 @@ +title = "Фактический табель #$model->id"; + +\yii\web\YiiAsset::register($this); +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ +// 'class' => 'btn btn-danger', +// 'data' => [ +// 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), +// 'method' => 'post', +// ], +// ]) ?> +

+ + $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"']) : ''; + }, + ], + ], + ]) ?> + +