]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Revert "Добавлены факт смены в /timetable/plan"
authorAlexander Smirnov <fredeom@mail.ru>
Mon, 1 Jul 2024 08:14:57 +0000 (11:14 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Mon, 1 Jul 2024 08:14:57 +0000 (11:14 +0300)
This reverts commit ab1294a5

erp24/actions/timetable/EditPlanAction.php
erp24/actions/timetable/PlanAction.php
erp24/forms/timetable/TabelSearchForm.php
erp24/records/Timetable.php
erp24/records/TimetableFactModel.php
erp24/views/timetable/plan.php
erp24/views/timetable/tabel_edit.php

index f5c5105f53c3431a071588d2b53d3eceb51f6c3c..652c481dae3b56f31b9041381ad209d3be04d8d6 100755 (executable)
@@ -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,
         ]);
     }
index 3fc4a8eef451f6149b6564ce530591dec0f8a8a1..d3a5858bab86de0175d9a8bc16fb3da30d3c990f 100755 (executable)
@@ -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,
         ]);
     }
 
index 1acbf3f311e818756eed395d5447029ee965d9f4..77716c206724a4d61a32aab3513e3db49626727d 100755 (executable)
@@ -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()
index 7cdc852102b54d4d2431a8ca23130049bb2696d2..4e87777e3cb46a184226a81e10fedb236acb26de 100755 (executable)
@@ -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;
index 7cb99e960e01f334779dd72576a860cc2bc9f7fa..baa534479408fb7a718150d65856a43d3ff1f3dc 100644 (file)
@@ -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,
index 9fe4af28ece4e42b6e14c52cf50491b56a5aff60..1b08908425b4a2421f5f2e5e4e2b2a5cd649e0e5 100755 (executable)
@@ -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;
 <?php
         $recordPlan = $regroupedTimetablePlan[$idu][$date->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;
                 <?= $slotTypeLetters[$recordPlan->slot_type_id]?? '#'; ?>
 <?php if ($recordPlan->isWorkSlot()) { ?><span class="color-success">+<?= $recordPlan->work_time; ?></span>
                 <?php } ?>
-                <?php if ($recordFactModels  && $recordPlan->isWorkSlot()) { ?>
-                <?php $rfm_work_time = 0; foreach ($recordFactModels as $rfm) { $rfm_work_time += $rfm->work_time ?? 0; } ?>
-                <div class="hours" <?= count($recordFactModels) > 1 ? 'style="background: yellow"' : '' ?>>Ф+<?= $rfm_work_time ?></div>
+                <?php if ($recordFact && $recordPlan->isWorkSlot()) { ?>
+                <div class="hours">Ф+<?= $recordFact->work_time ?></div>
                 <?php } ?>
             <?php } ?>
             </div>
index 8544495730fabd2915b5c3bb423e1fc8f31c8235..fdc38e2612858500b6c5791b57dd2350a9f41263 100755 (executable)
@@ -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)) {
     <?php
 } ?>
 <?php $form::end() ?>
-
-<h3 class="m-2">Факты смены:</h3>
-
-<div class="table-responsive">
-<?= \yii\grid\GridView::widget([
-    'dataProvider' => $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 . "<br>" . $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') . "<br>" .
-                    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') . "<br>" .
-                    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 '';
-            },
-        ],
-    ],
-]); ?>
-</div>
\ No newline at end of file