From 0d91ef5d7d048f83df1ac0bf567e1ef0835f8dfa Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 27 Dec 2016 19:32:15 +0200 Subject: [PATCH] -Delete action added --- frontend/controllers/CabinetController.php | 40 ++++++++++++++++++++++++++++++++++++++++ frontend/models/CreativeRole.php | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------- frontend/views/cabinet/sales.php | 218 ++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- frontend/web/css/cabinet-style.css | 4 ++-- frontend/web/js/script.js | 26 ++++++++++++++++++++++++++ 5 files changed, 192 insertions(+), 239 deletions(-) diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php index a87666f..c1e8a53 100644 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php @@ -2,6 +2,7 @@ namespace frontend\controllers; use common\models\User; + use frontend\models\CreativeRole; use frontend\models\IntellectualProperty; use frontend\models\UserData; use frontend\models\UserPassport; @@ -91,10 +92,16 @@ ]; } } + + $table = CreativeRole::find()->where([ + 'intellectual_property_id' => $id + ])->all(); + return $this->render( 'sales', [ 'property' => $property, + 'table' => $table ] ); } @@ -193,6 +200,39 @@ ]; } } + + public function actionAddRole() + { + $request = \Yii::$app->request; + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + + $role = new CreativeRole(); + + if ($role->load($request->post()) && $role->save()) { + return [ + 'success' => true, + 'message' => 'Данные успешно сохранены', + ]; + } else { + return [ + 'error' => true, + 'message' => 'Ошибка сохранения данных', + ]; + } + } + + public function actionDeleteRole() + { + $request = \Yii::$app->request; + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + + return [ + 'message' => 'ok' . $request->post('id'), + ]; + + } public function findProperty($id) { diff --git a/frontend/models/CreativeRole.php b/frontend/models/CreativeRole.php index 31eee76..1f60580 100644 --- a/frontend/models/CreativeRole.php +++ b/frontend/models/CreativeRole.php @@ -1,66 +1,87 @@ 255, + ], + [ + [ 'intellectual_property_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => IntellectualProperty::className(), + 'targetAttribute' => [ 'intellectual_property_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'intellectual_property_id' => 'Intellectual Property ID', + 'title' => 'Творча роль', + 'name' => 'ПІБ', + 'part' => 'Доля %', + 'code' => 'Код', + 'iri' => 'IPI', + 'society' => 'Товариство', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getIntellectualProperty() + { + return $this->hasOne(IntellectualProperty::className(), [ 'id' => 'intellectual_property_id' ]); + } } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['intellectual_property_id'], 'integer'], - [['part'], 'number'], - [['title', 'name', 'code', 'iri', 'society'], 'string', 'max' => 255], - [['intellectual_property_id'], 'exist', 'skipOnError' => true, 'targetClass' => IntellectualProperty::className(), 'targetAttribute' => ['intellectual_property_id' => 'id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'intellectual_property_id' => 'Intellectual Property ID', - 'title' => 'Title', - 'name' => 'Name', - 'part' => 'Part', - 'code' => 'Code', - 'iri' => 'Iri', - 'society' => 'Society', - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getIntellectualProperty() - { - return $this->hasOne(IntellectualProperty::className(), ['id' => 'intellectual_property_id']); - } -} diff --git a/frontend/views/cabinet/sales.php b/frontend/views/cabinet/sales.php index 20d169b..5a9d9b0 100644 --- a/frontend/views/cabinet/sales.php +++ b/frontend/views/cabinet/sales.php @@ -1,4 +1,5 @@
@@ -139,12 +141,12 @@
'button', 'class' => 'add-role-button', 'data-toggle' => 'modal', - 'data-target' => '#add-composition-modal', + 'data-target' => '#add-role-modal', ] ) ?>
@@ -152,6 +154,11 @@
+ 'roles-table', + ]); + ?> @@ -162,167 +169,26 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + +
Творча рольТовариство
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- title ?>name ?>part ?>code ?>iri ?>society ?> +
+
@@ -340,55 +206,55 @@
-