From: Alexander Smirnov Date: Mon, 1 Jul 2024 08:14:57 +0000 (+0300) Subject: Revert "Добавлены факт смены в /timetable/plan" X-Git-Tag: 1.3~33^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=d039a031192617d2639e9c56fce57d577c288453;p=erp24_rep%2Fyii-erp24%2F.git Revert "Добавлены факт смены в /timetable/plan" This reverts commit ab1294a5 --- diff --git a/erp24/actions/timetable/EditPlanAction.php b/erp24/actions/timetable/EditPlanAction.php index f5c5105f..652c481d 100755 --- a/erp24/actions/timetable/EditPlanAction.php +++ b/erp24/actions/timetable/EditPlanAction.php @@ -6,7 +6,6 @@ namespace yii_app\actions\timetable; use yii_app\records\TimetableFactModel; use Yii; use yii\base\Action; -use yii\data\ActiveDataProvider; use yii\web\Response; use yii_app\records\Admin; use yii_app\records\Timetable; @@ -65,11 +64,9 @@ class EditPlanAction extends Action $slot->time_end = $slot->shift ? $slot->shift->end_time : null; } $fact = TimetableFact::find()->andWhere(['plan_id' => $slot->id])->one(); - $dataProvider = new ActiveDataProvider(['query' => TimetableFactModel::find()->where(['admin_id' => $row['admin_id'], 'store_id' => $row['store_id'], 'date_shift' => $row['date']])]); return $this->controller->renderPartial('/timetable/tabel_edit.php', [ 'slot' => $slot, 'fact' => $fact, - 'dataProvider' => $dataProvider, 'success' => $success ?? false, ]); } diff --git a/erp24/actions/timetable/PlanAction.php b/erp24/actions/timetable/PlanAction.php index 3fc4a8ee..d3a5858b 100755 --- a/erp24/actions/timetable/PlanAction.php +++ b/erp24/actions/timetable/PlanAction.php @@ -3,7 +3,6 @@ declare(strict_types = 1); namespace yii_app\actions\timetable; -use yii_app\records\TimetableFactModel; use yii\base\Action; use yii\helpers\ArrayHelper; use yii_app\forms\timetable\TabelSearchForm; @@ -23,7 +22,6 @@ class PlanAction extends Action 'tabelForm' => $tabelForm, 'timetablePlan' => [], 'timetableFact' => [], - 'timetableFactModel' => [], ]); } @@ -52,13 +50,10 @@ class PlanAction extends Action /** @var TimetableFact[] $timetablePlan */ $timetableFact = array_filter(ArrayHelper::getColumn($timetablePlan, 'fact')); - $timetableFactModel = $tabelForm->search(Timetable::TABLE_FACT_NEW)->all(); - return $this->controller->render('/timetable/plan.php', [ 'tabelForm' => $tabelForm, 'timetablePlan' => $timetablePlan, 'timetableFact' => $timetableFact, - 'timetableFactModel' => $timetableFactModel, ]); } diff --git a/erp24/forms/timetable/TabelSearchForm.php b/erp24/forms/timetable/TabelSearchForm.php index 1acbf3f3..77716c20 100755 --- a/erp24/forms/timetable/TabelSearchForm.php +++ b/erp24/forms/timetable/TabelSearchForm.php @@ -3,7 +3,6 @@ declare(strict_types = 1); namespace yii_app\forms\timetable; -use yii_app\records\TimetableFactModel; use yii\base\Model; use yii\db\ActiveQuery; use yii\db\Expression; @@ -105,32 +104,25 @@ class TabelSearchForm extends Model $classes = [ Timetable::TABLE_PLAN => TimetablePlan::class, Timetable::TABLE_FACT => TimetableFact::class, - Timetable::TABLE_FACT_NEW => TimetableFactModel::class, ]; if (!isset($classes[$tabel])) { throw new \Exception('Unknown type'); } - /** @var TimetablePlan | TimetableFact | TimetableFactModel $class */ + /** @var TimetablePlan | TimetableFact $class */ $class = $classes[$tabel]; - if (in_array($tabel, [Timetable::TABLE_PLAN, Timetable::TABLE_FACT])) { - return $class::find() - ->andWhere([ - 'admin_group_id' => array_keys(AdminGroup::groupsWithShift()), - 'store_id' => array_keys(self::stores()), - ]) - ->andFilterWhere([ - 'admin_group_id' => $this->adminGroupId, - 'store_id' => $this->storeId, - 'status' => $this->status, - ]) - ->andFilterWhere(['>=', 'date', $this->start]) - ->andFilterWhere(['<=', 'date', $this->end]); - } else { - return $class::find() - ->andWhere(['store_id' => array_keys(self::stores())]) - ->andFilterWhere(['>=', 'date_shift', $this->start]) - ->andFilterWhere(['<=', 'date_shift', $this->end]); - } + return $class::find() + ->andWhere([ + 'admin_group_id' => array_keys(AdminGroup::groupsWithShift()), + 'store_id' => array_keys(self::stores()), + ]) + ->andFilterWhere([ + 'admin_group_id' => $this->adminGroupId, + 'store_id' => $this->storeId, + 'status' => $this->status, + ]) + ->andFilterWhere(['>=', 'date', $this->start]) + ->andFilterWhere(['<=', 'date', $this->end]) + ; } public function holidays() diff --git a/erp24/records/Timetable.php b/erp24/records/Timetable.php index 7cdc8521..4e87777e 100755 --- a/erp24/records/Timetable.php +++ b/erp24/records/Timetable.php @@ -43,7 +43,6 @@ class Timetable extends ActiveRecord const TABLE_PLAN = 0; const TABLE_FACT = 1; - const TABLE_FACT_NEW = 2; const TIMESLOT_WORK = 1; const TIMESLOT_VACATION = 2; diff --git a/erp24/records/TimetableFactModel.php b/erp24/records/TimetableFactModel.php index 7cb99e96..baa53447 100644 --- a/erp24/records/TimetableFactModel.php +++ b/erp24/records/TimetableFactModel.php @@ -208,10 +208,6 @@ class TimetableFactModel extends ActiveRecord return $this->hasOne(AdminGroup::class, ['id' => 'admin_group_id']); } - public function isWorkSlot() { - return true; - } - public static function getClosedShiftData($admin_id, $date_start, $date_end) { $timetableFactModels = TimetableFactModel::find()->where([ 'admin_id' => $admin_id, diff --git a/erp24/views/timetable/plan.php b/erp24/views/timetable/plan.php index 9fe4af28..1b089084 100755 --- a/erp24/views/timetable/plan.php +++ b/erp24/views/timetable/plan.php @@ -4,12 +4,10 @@ * @var TabelSearchForm $tabelForm * @var Timetable[] $timetablePlan * @var Timetable[] $timetableFact - * @var TimetableFactModel[] $timetableFactModel * @var array $userSummaryPlan * @var array $userSummaryFact */ -use yii_app\records\TimetableFactModel; use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\widgets\ActiveForm; @@ -28,7 +26,7 @@ $holidays = ArrayHelper::index($tabelForm->holidays(), 'date'); $getUserSummary = function (array $timetable) { $userSummary = []; - /** @var TimetablePlan[] | TimetableFactModel $timetable */ + /** @var TimetablePlan[] $timetable */ foreach ($timetable as $slot) { $userSummary[$slot->admin_id] ??= [ 'time' => 0, @@ -43,7 +41,6 @@ $getUserSummary = function (array $timetable) { }; $userSummaryPlan = $getUserSummary($timetablePlan); $userSummaryFact = $getUserSummary($timetableFact); -$userSummaryFactModel = $getUserSummary($timetableFactModel); $allShifts = \yii_app\records\Shift::all(); $adminGroups = AdminGroup::groupsWithShift(); @@ -190,11 +187,6 @@ $users = $tabelForm->admins(); $regroupedTimetablePlan = ArrayHelper::index($timetablePlan, 'date', ['admin_id']); /** @var Timetable[][] $regroupedTimetableFact */ $regroupedTimetableFact = ArrayHelper::index($timetableFact, 'date', ['admin_id']); -/** @var TimetableFactModel[][] $regroupedTimetableFactModel */ -$regroupedTimetableFactModel = []; -foreach($timetableFactModel as $ttfm) { - $regroupedTimetableFactModel[$ttfm->admin_id][$ttfm->date_shift][] = $ttfm; -} $rowNumber = 0; ?> @@ -216,7 +208,6 @@ $rowNumber = 0; format('Y-m-d')] ?? null; $recordFact = $regroupedTimetableFact[$idu][$date->format('Y-m-d')] ?? null; - $recordFactModels = $regroupedTimetableFactModel[$idu][$date->format('Y-m-d')] ?? null; $attributes = [ 'class' => ['day' . $date->format('N')], 'data-user-id' => $user->id, @@ -241,9 +232,8 @@ $rowNumber = 0; slot_type_id]?? '#'; ?> isWorkSlot()) { ?>+work_time; ?> - isWorkSlot()) { ?> - work_time ?? 0; } ?> -
1 ? 'style="background: yellow"' : '' ?>>Ф+
+ isWorkSlot()) { ?> +
Ф+work_time ?>
diff --git a/erp24/views/timetable/tabel_edit.php b/erp24/views/timetable/tabel_edit.php index 85444957..fdc38e26 100755 --- a/erp24/views/timetable/tabel_edit.php +++ b/erp24/views/timetable/tabel_edit.php @@ -2,12 +2,9 @@ /** * @var \yii_app\records\Timetable $slot * @var \yii_app\records\TimetableFact $fact - * @var \yii\data\ActiveDataProvider $dataProvider * @var bool $success */ -use yii\grid\ActionColumn; -use yii\helpers\Html; use yii\helpers\ArrayHelper; use yii_app\records\AdminGroup; use yii_app\records\Timetable; @@ -101,87 +98,3 @@ if (Timetable::getAllowEditShift($slot->date, $numDay)) { - -

Факты смены:

- -
- $dataProvider, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - [ - 'attribute' => 'admin_id', - 'label' => 'Пользователь', - 'value' => function ($data) { - return $data->admin->name; - } - ], - [ - 'attribute' => 'store_id', - 'label' => 'Магазин, Должность', - 'format' => 'raw', - 'value' => function ($data) { - return $data->store->name . "
" . $data->adminGroup->name; - } - ], - [ - 'label' => 'Тип смены', - 'attribute' => 'shift_id', - 'format' => 'raw', - 'value' => function ($model) { - return $model->shift_id ? $model->shift->name : null; - }, - ], - [ - 'attribute' => 'work_time', - 'format' => 'raw', - 'value' => function ($model) { - return $model->work_time; - }, - ], - [ - 'label' => 'Дата смены', - 'attribute' => 'date_shift', - 'format' => ['date', 'php:d.m.Y'], - ], - [ - 'label' => 'Начало', - 'attribute' => 'date_start', - 'format' => 'raw', - 'value' => function ($model) { - return Yii::$app->formatter->asDatetime($model->date_start, 'php:d.m.Y') . "
" . - Yii::$app->formatter->asDatetime($model->time_start, 'php:H:i:s'); - }, - ], - [ - 'label' => 'Конец', - 'attribute' => 'date_end', - 'format' => 'raw', - 'value' => function ($model) { - return !empty($model->date_end) ? Yii::$app->formatter->asDatetime($model->date_end, 'php:d.m.Y') . "
" . - Yii::$app->formatter->asDatetime($model->time_end, 'php:H:i:s') : 'Работает'; - }, - ], - [ - 'label' => 'Отметка о начале', - 'format' => 'raw', - 'value' => function ($model) { - if (!empty($model->checkin_start_id)) { - return !empty($photo = $model->checkinStart->photo) ? Html::img("/$photo", ['alt' => 'selfie', 'style' => 'min-width: 200px']) : null; - }; - return ''; - }, - ], - [ - 'label' => 'Отметка о конце', - 'format' => 'raw', - 'value' => function ($model) { - if (!empty($model->checkin_end_id)) { - return !empty($photo = $model->checkinEnd->photo) ? Html::img("/$photo", ['alt' => 'selfie', 'style' => 'min-width: 200px']) : null; - }; - return ''; - }, - ], - ], -]); ?> -
\ No newline at end of file