1234567891011121314151617181920212223242526272829303132 |
- <?php /** Created by Anton on 07.02.2020. */
- require '../yiiInit.php';
- use app\models\entity\Tmc;
- use app\models\entity\TmcStatus;
- use app\models\entity\Log;
- use yii\helpers\Url;
- $inventoryNum = Yii::$app->request->post('inventoryNum');
- $note = Yii::$app->request->post('reason');
- $company = Yii::$app->request->post('company');
- $userId = Yii::$app->request->post('user');
- $tmc = Tmc::findOne([
- 'inventory_num' => $inventoryNum,
- 'company' => $company
- ]);
- if ($tmc) {
- $tmc->status = TmcStatus::TMC_STATUS_REPAIR;
- $tmc->save();
- $log = new Log();
- $log->tmc = $tmc->id;
- $log->employee = $userId;
- $log->issue_date = (new DateTime())->format('Y-m-d H:i:s');
- $log->note = $note;
- $log->save();
- }
- Yii::$app->response->redirect(Url::to($_SERVER['HTTP_REFERER']))->send();
|