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 [
[['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'],
];
}
$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();
}
}
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']);
--- /dev/null
+<?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>