write_off_device.php 867 B

1234567891011121314151617181920212223242526272829
  1. <?php /** Created by Anton on 11.02.2020. */
  2. require '../yiiInit.php';
  3. $inventoryNum = Yii::$app->request->post('inventoryNum');
  4. $desc = Yii::$app->request->post('desc');
  5. $company = (int)Yii::$app->request->post('company');
  6. $user = (int)Yii::$app->request->post('user');
  7. $tmc = \app\models\entity\Tmc::findOne(['inventory_num' => $inventoryNum, 'company' => $company]);
  8. if (!$tmc) {
  9. die('Устройство не найдено');
  10. }
  11. $now = (new \DateTime())->format('Y-m-d H:i:s');
  12. $tmc->write_off_date = $now;
  13. $tmc->status = \app\models\entity\TmcStatus::TMC_STATUS_DECOMMISSION;
  14. $tmc->save();
  15. $log = new \app\models\entity\Log();
  16. $log->receipt_date = $now;
  17. $log->employee = $user;
  18. $log->tmc = $tmc->id;
  19. $log->note = $desc;
  20. $log->save();
  21. Yii::$app->response->redirect(yii\helpers\Url::to($_SERVER['HTTP_REFERER']))->send();