1234567891011121314151617181920212223242526272829303132 |
- <?php /** Created by Anton on 17.02.2020. */
- use app\models\entity\Storage;
- use app\models\entity\Tmc;
- use yii\helpers\Url;
- require '../yiiInit.php';
- $inventoryNum = Yii::$app->request->post('inventoryNum');
- $ip = Yii::$app->request->post('characteristic');
- $storageId = (int)Yii::$app->request->post('storage');
- $desc = Yii::$app->request->post('desc');
- $tmc = Tmc::findOne(['inventory_num' => $inventoryNum]);
- if (!$tmc) {
- die('Устройство не найдено');
- }
- $storage = Storage::findOne($storageId);
- if (!$tmc) {
- die('Хранилище не найдено');
- }
- $tmc->storage = $storage->id;
- $tmc->ip = $ip;
- $tmc->desc = $desc;
- $tmc->save();
- $storage->tmc = $tmc->id;
- $storage->save();
- Yii::$app->response->redirect(Url::to($_SERVER['HTTP_REFERER']))->send();
|