add_repair.php 839 B

1234567891011121314151617181920212223242526272829303132
  1. <?php /** Created by Anton on 07.02.2020. */
  2. require '../yiiInit.php';
  3. use app\models\entity\Tmc;
  4. use app\models\entity\TmcStatus;
  5. use app\models\entity\Log;
  6. use yii\helpers\Url;
  7. $inventoryNum = Yii::$app->request->post('inventoryNum');
  8. $note = Yii::$app->request->post('reason');
  9. $company = Yii::$app->request->post('company');
  10. $userId = Yii::$app->request->post('user');
  11. $tmc = Tmc::findOne([
  12. 'inventory_num' => $inventoryNum,
  13. 'company' => $company
  14. ]);
  15. if ($tmc) {
  16. $tmc->status = TmcStatus::TMC_STATUS_REPAIR;
  17. $tmc->save();
  18. $log = new Log();
  19. $log->tmc = $tmc->id;
  20. $log->employee = $userId;
  21. $log->issue_date = (new DateTime())->format('Y-m-d H:i:s');
  22. $log->note = $note;
  23. $log->save();
  24. }
  25. Yii::$app->response->redirect(Url::to($_SERVER['HTTP_REFERER']))->send();