]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
мелко правки
authormarina <m.zozirova@gmail.com>
Thu, 4 Jul 2024 06:44:07 +0000 (09:44 +0300)
committermarina <m.zozirova@gmail.com>
Thu, 4 Jul 2024 06:44:07 +0000 (09:44 +0300)
erp24/controllers/TimetableFactController.php
erp24/records/TimetableFactModel.php

index a24d7cefbb095a0ce376a55a4a8365fae5973fbd..3f1ea30fce5fe29631985d6d4d7f8b6bd2c382ee 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace app\controllers;
 
-use app\records\TimetableFactModel;
 use yii\data\ActiveDataProvider;
 use yii\db\Query;
 use yii\web\Controller;
@@ -11,6 +10,7 @@ use yii\filters\VerbFilter;
 use yii_app\records\Admin;
 use yii_app\records\AdminCheckin;
 use yii_app\records\Timetable;
+use yii_app\records\TimetableFactModel;
 
 /**
  * TimetableFactController implements the CRUD actions for TimetableFactModel model.
@@ -158,8 +158,7 @@ class TimetableFactController extends Controller
             ->andWhere(['is not', 'plan_id', null])
             ->andWhere(['not in', 'id', (new Query())->select('plan_id')->from('timetable_fact')]);
 
-
-        if ($action == 'applyPlus') {
+        if ($action == 'applyPlus' || true) {
 
             $timetables = Timetable::find()
                 ->andWhere(['>=', 'date', '2024-06-01'])
@@ -167,6 +166,7 @@ class TimetableFactController extends Controller
                 ->andWhere(['is not', 'plan_id', null])
                 ->all();
 
+
             foreach ($timetables as $timetable) {
                 $newFact = TimetableFactModel::find()
                     ->andWhere(['date_shift' => $timetable->date])
@@ -175,32 +175,26 @@ class TimetableFactController extends Controller
                     ->one();
 
                 if ($newFact) {
-                    var_dump($newFact);die();
-                    $newFact->plan_id = $timetable->id;
+                    $newFact->plan_id = $timetable->plan_id;
                     $newFact->tabel = $timetable->tabel;
                     $newFact->save();
                 } else {
                     $adminCheckinStart = AdminCheckin::find()
-                        ->where(['plan_id' => $timetable->id])
+                        ->where(['plan_id' => $timetable->plan_id])
                         ->orderBy('id asc')
                         ->one();
 
                     $adminCheckinEnd = AdminCheckin::find()
-                        ->where(['plan_id' => $timetable->id])
+                        ->where(['plan_id' => $timetable->plan_id])
                         ->orderBy('id desc')
                         ->one();
 
                     if ($adminCheckinStart) {
                         $adminCheckinStart->shift_id = $timetable->shift_id;
-                        var_dump($timetable->shift_id);
-                        var_dump($adminCheckinStart->shift_id);
                         TimetableFactModel::setValues($adminCheckinStart);
 
                         if ($adminCheckinEnd && $adminCheckinStart->id != $adminCheckinEnd->id) {
                             $adminCheckinEnd->shift_id = $timetable->shift_id;
-                            var_dump($timetable->shift_id);
-                            var_dump($adminCheckinStart->shift_id);
-                            die();
                             TimetableFactModel::setValues($adminCheckinEnd);
                         }
                     }
index 85489137a96b052f1d5c336a9827b8b9a55f604e..9176e52cf099b9492141562deb41ed8d02c2a7be 100644 (file)
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace app\records;
+namespace yii_app\records;
 
 use Throwable;
 use yii\db\ActiveRecord;
@@ -126,7 +126,7 @@ class TimetableFactModel extends ActiveRecord
             $model->status = AdminCheckin::TYPE_START;
             $model->checkin_start_id = $adminCheckin->id;
 
-            $timetable = Timetable::findOne(['date' => $adminCheckin->date, 'admin_id' => $adminCheckin->admin_id]);
+            $timetable = Timetable::findOne(['plan_id' => $adminCheckin->plan_id]);
 
             if (!empty($timetable)) {
                 $model->tabel = 1;