]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
del old employee on shift in initial and rejected state
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 30 May 2024 15:58:18 +0000 (18:58 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 30 May 2024 15:58:18 +0000 (18:58 +0300)
erp24/api3/modules/v1/controllers/claim/WorkerController.php

index e0b0a9de4a608cf92a7bc3e6a71b31f011478a1d..057496cdf60f5cc3dfb63d90e295557e81625a21 100644 (file)
@@ -9,6 +9,7 @@ use yii_app\api3\core\traits\ServiceTrait;
 use yii_app\api3\helpers\Util;
 use yii_app\api3\modules\v1\requests\claim\Worker;
 use yii_app\api3\modules\v1\requests\claim\WorkerControl;
+use yii_app\records\EmployeeOnShift;
 
 /**
  * @property ClaimService $claimService
@@ -45,6 +46,13 @@ class WorkerController extends \yii_app\api3\controllers\ActiveController
 
     public function actionCreate()
     {
+        // Удаляем старые заявки
+        EmployeeOnShift::deleteAll([
+            'and',
+            ['status' => [EmployeeOnShift::STATUS_INITIAL, EmployeeOnShift::STATUS_REJECT]],
+            ['<=', 'created_at', date('Y-m-d H:i:s', strtotime('-30 minutes', time()))]
+        ]);
+
         $params = Yii::$app->request->bodyParams;
         $data = $this->validate(new Worker(), $params);