edit.php 825 B

1234567891011121314151617181920212223242526272829303132
  1. <?php /** Created by Anton on 17.02.2020. */
  2. use app\models\entity\Storage;
  3. use app\models\entity\Tmc;
  4. use yii\helpers\Url;
  5. require '../yiiInit.php';
  6. $inventoryNum = Yii::$app->request->post('inventoryNum');
  7. $ip = Yii::$app->request->post('characteristic');
  8. $storageId = (int)Yii::$app->request->post('storage');
  9. $desc = Yii::$app->request->post('desc');
  10. $tmc = Tmc::findOne(['inventory_num' => $inventoryNum]);
  11. if (!$tmc) {
  12. die('Устройство не найдено');
  13. }
  14. $storage = Storage::findOne($storageId);
  15. if (!$tmc) {
  16. die('Хранилище не найдено');
  17. }
  18. $tmc->storage = $storage->id;
  19. $tmc->ip = $ip;
  20. $tmc->desc = $desc;
  21. $tmc->save();
  22. $storage->tmc = $tmc->id;
  23. $storage->save();
  24. Yii::$app->response->redirect(Url::to($_SERVER['HTTP_REFERER']))->send();