diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php index 08ce1db..c3f07f8 100644 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php @@ -2,11 +2,13 @@ namespace frontend\controllers; use common\models\User; + use frontend\models\IntellectualProperty; use frontend\models\UserData; use frontend\models\UserPassport; use yii\filters\VerbFilter; use yii\web\Controller; - + use yii\web\NotFoundHttpException; + /** * Cabinet controller */ @@ -55,9 +57,24 @@ ]); } - public function actionSales() + public function actionSales($id = null) { - + if($id) { + $property = $this->findProperty($id); + } else { + $property = new IntellectualProperty(); + } + if($property->load(\Yii::$app->request->post()) && $property->save()) { + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + return [ + 'success' => true, + 'message' => 'Данные успешно сохранены', + ]; + } + return $this->render('sales', [ + 'property' => $property, + ]); } public function actionPersonal() @@ -111,4 +128,13 @@ ]; } } + + public function findProperty($id) + { + $model = IntellectualProperty::findOne($id); + if(empty($model)) { + throw new NotFoundHttpException(); + } + return $model; + } } diff --git a/frontend/models/IntellectualProperty.php b/frontend/models/IntellectualProperty.php index 381b6cc..f14a4c3 100644 --- a/frontend/models/IntellectualProperty.php +++ b/frontend/models/IntellectualProperty.php @@ -51,13 +51,13 @@ class IntellectualProperty extends \yii\db\ActiveRecord return [ 'id' => 'ID', 'user_id' => 'User ID', - 'title' => 'Title', - 'creation_date' => 'Creation Date', - 'code' => 'Code', - 'genre' => 'Genre', - 'registration_date' => 'Registration Date', - 'contract' => 'Contract', - 'type' => 'Type', + 'title' => 'Назва', + 'creation_date' => 'Дата створення', + 'code' => 'Шифр', + 'genre' => 'Жанр', + 'registration_date' => 'Дата реєстрації', + 'contract' => 'Договір', + 'type' => 'Тип', ]; } diff --git a/frontend/views/cabinet/index.php b/frontend/views/cabinet/index.php index 2f7cdfe..e264176 100644 --- a/frontend/views/cabinet/index.php +++ b/frontend/views/cabinet/index.php @@ -213,1286 +213,6 @@