From d67e50b22d1c055488e356bc435c6c1c5263f27b Mon Sep 17 00:00:00 2001 From: marina Date: Wed, 18 Sep 2024 12:00:16 +0300 Subject: [PATCH] =?utf8?q?ERP-175=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?utf8?q?=D0=B8=D1=82=D1=8C=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?utf8?q?=D0=B2=D0=BE=D1=80=D0=BA-=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BA=D0=BE?= =?utf8?q?=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=B0=D1=8F=20=D0=B2=D0=B5?= =?utf8?q?=D1=80=D1=81=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api3/core/services/TimetableService.php | 15 ++++----------- .../v1/controllers/timetable/FactController.php | 3 ++- .../v1/controllers/timetable/PlanController.php | 15 ++------------- .../modules/v1/models/timetable/Timetable.php | 16 ++++------------ erp24/records/AdminCheckin.php | 4 ++-- 5 files changed, 14 insertions(+), 39 deletions(-) diff --git a/erp24/api3/core/services/TimetableService.php b/erp24/api3/core/services/TimetableService.php index 197e4047..a4a04520 100644 --- a/erp24/api3/core/services/TimetableService.php +++ b/erp24/api3/core/services/TimetableService.php @@ -149,17 +149,10 @@ class TimetableService $checkIn = new AdminCheckin(); - $timetable = Timetable::find() - ->andWhere(['admin_id' => $admin_id]) - ->andWhere(['between', 'date', date('Y-m-d', strtotime('-1 day')), date('Y-m-d')]) -// ->andWhere(['tabel' => 1]) - ->orderBy('id desc') - ->one(); - - $checkIn->plan_id = $timetable->plan_id; - $checkIn->store_id = $timetable->store_id; - $checkIn->d_id = $timetable->admin->group_id; - $checkIn->date = $timetable->date; + $checkIn->plan_id = $fact->plan_id; + $checkIn->store_id = $fact->store_id; + $checkIn->d_id = $fact->admin->group_id; + $checkIn->date = $fact->date_shift; $checkIn->ball = 5; $checkIn->comment = ""; $checkIn->admin_id = $admin_id; diff --git a/erp24/api3/modules/v1/controllers/timetable/FactController.php b/erp24/api3/modules/v1/controllers/timetable/FactController.php index 6585682a..93de0f5a 100644 --- a/erp24/api3/modules/v1/controllers/timetable/FactController.php +++ b/erp24/api3/modules/v1/controllers/timetable/FactController.php @@ -7,6 +7,7 @@ use yii_app\api3\controllers\ActiveController; use yii_app\api3\core\services\TimetableService; use yii_app\api3\core\traits\ServiceTrait; use yii_app\api3\modules\v1\requests\timetable\Fact; +use yii_app\records\TimetableFactModel; /** * @property TimetableService $timetableService @@ -15,7 +16,7 @@ class FactController extends ActiveController { use ServiceTrait; - public $modelClass = \yii_app\api3\modules\v1\requests\timetable\Fact::class; + public $modelClass = TimetableFactModel::class; public function actions() { diff --git a/erp24/api3/modules/v1/controllers/timetable/PlanController.php b/erp24/api3/modules/v1/controllers/timetable/PlanController.php index 2ae7b68e..0f1ef6ed 100644 --- a/erp24/api3/modules/v1/controllers/timetable/PlanController.php +++ b/erp24/api3/modules/v1/controllers/timetable/PlanController.php @@ -20,7 +20,7 @@ class PlanController extends \yii_app\api3\controllers\ActiveController use ServiceTrait; - public $modelClass = TimetableFactModel::class; + public $modelClass = Timetable::class; public function actions() @@ -32,22 +32,11 @@ class PlanController extends \yii_app\api3\controllers\ActiveController 'pageSizeLimit' => [1, 50], ]; - $request = Yii::$app->request->post()['filter']; - - $fact = TimetableFactModel::find() - ->andWhere(['admin_id' => $request['admin_id']]) - ->andWhere(['date_shift' => $request['date']]) - ->one(); - - if (true) { - $this->modelClass = \yii_app\api3\modules\v1\models\timetable\Timetable::class; - } - $actions['index']['dataFilter'] = [ 'class' => \yii\data\ActiveDataFilter::class, 'searchModel' => $actions['index']['modelClass'] ]; - var_dump($actions['index']);die(); + unset($actions['delete']); return $actions; diff --git a/erp24/api3/modules/v1/models/timetable/Timetable.php b/erp24/api3/modules/v1/models/timetable/Timetable.php index e380916d..c9681b24 100644 --- a/erp24/api3/modules/v1/models/timetable/Timetable.php +++ b/erp24/api3/modules/v1/models/timetable/Timetable.php @@ -182,19 +182,11 @@ class Timetable extends \yii_app\records\TimetableV3 { return $this->hasOne(CityStore::class, ['id' => 'store_id']); } - - public function getCheckIns() - { - return $this->hasMany(AdminCheckin::class, ['admin_id' => 'admin_id']) - ->andWhere(['BETWEEN', 'time', date('Y-m-d H:i:s', strtotime('-6 hour')), date('Y-m-d H:i:s', strtotime('+6 hour'))]); - + public function getCheckIns() { + return $this->hasMany(AdminCheckin::class, ['plan_id' => 'id']); } - public function getCheckInCount() - { - return $this->hasMany(AdminCheckin::class, ['admin_id' => 'admin_id']) - ->andWhere(['BETWEEN', 'time', date('Y-m-d H:i:s'), date('Y-m-d H:i:s', strtotime('+6 hour'))]) - ->andWhere(['BETWEEN', 'time', date('Y-m-d H:i:s', strtotime('-6 hour')), date('Y-m-d H:i:s')])->count(); - + public function getCheckInCount() { + return $this->hasMany(AdminCheckin::class, ['plan_id' => 'id'])->count(); } } \ No newline at end of file diff --git a/erp24/records/AdminCheckin.php b/erp24/records/AdminCheckin.php index 91f32ea7..329b2e83 100755 --- a/erp24/records/AdminCheckin.php +++ b/erp24/records/AdminCheckin.php @@ -87,9 +87,9 @@ class AdminCheckin extends ActiveRecord public function rules() { return [ - [['admin_id', 'device_id', 'replaced_admin_id', 'plan_id', 'store_id', 'type_id', 'd_id', 'ball', 'status'], 'integer'], + [['admin_id', 'device_id', 'replaced_admin_id', 'store_id', 'type_id', 'd_id', 'ball', 'status'], 'integer'], [['lat', 'lon'], 'double'], - [['shift_id'], 'safe'], + [['shift_id', 'plan_id'], 'safe'], [['comment', 'photo'], 'string'], [['date'], 'date', 'format' => 'yyyy-M-d'], // [['time'], 'date', 'format' => 'yyyy-M-d HH:mm:ss'], -- 2.39.5