diff --git a/common/models/User.php b/common/models/User.php index d388f50..47e4bd9 100755 --- a/common/models/User.php +++ b/common/models/User.php @@ -226,7 +226,7 @@ { return $this->hasOne(UserPassport::className(), [ 'user_id' => 'id' ]); } - + /** * @return bool * @todo change this @@ -239,4 +239,18 @@ return false; } } + + public function afterSave($insert, $changedAttributes) + { + if ($insert) { + ( new UserData( + [ + 'user_id' => $this->id, + 'name' => $this->username, + ] + ) )->save(false); + ( new UserPassport([ 'user_id' => $this->id ]) )->save(false); + } + parent::afterSave($insert, $changedAttributes); + } } diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php index 8fcbe26..652f584 100755 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php @@ -26,7 +26,7 @@ public function behaviors() { return [ - 'verbs' => [ + 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'personal' => [ 'post' ], @@ -38,7 +38,7 @@ 'rules' => [ [ 'allow' => true, - 'roles' => ['@'], + 'roles' => [ '@' ], ], ], ], @@ -63,13 +63,13 @@ $userPassport = new UserPassport(); } - $table = IntellectualProperty::find() -// ->where( -// [ -// 'user_id' => \Yii::$app->user->identity->id, -// ] -// ) - ->all(); + $tableQuery = IntellectualProperty::find(); + if (!$user->isAdmin()) { + $tableQuery->joinWith('creativeRoles') + ->where([ 'intellectual_property.user_id' => $user->id ]) + ->orWhere([ 'creative_role.user_id' => $user->id ]); + } + $table = $tableQuery->all(); return $this->render( 'index', @@ -127,12 +127,11 @@ public function actionList() { - $table = IntellectualProperty::find() -// ->where( -// [ -// 'user_id' => \Yii::$app->user->identity->id, -// ] -// ) + $table = IntellectualProperty::find()// ->where( + // [ + // 'user_id' => \Yii::$app->user->identity->id, + // ] + // ) ->all(); return $this->render( 'list', @@ -157,10 +156,14 @@ public function actionNotifications() { - $table = Report::find()->all(); - return $this->render('notifications', [ - 'table' => $table, - ]); + $table = Report::find() + ->all(); + return $this->render( + 'notifications', + [ + 'table' => $table, + ] + ); } public function actionUsers() @@ -320,15 +323,15 @@ ]; } } - + public function actionUpdateRole() { $request = \Yii::$app->request; $response = \Yii::$app->response; $response->format = $response::FORMAT_JSON; - + $role = CreativeRole::findOne($request->get('id')); - + if ($role->load($request->post()) && $role->save()) { return [ 'success' => true, @@ -341,17 +344,17 @@ ]; } } - + public function actionGetRoleForm() { $request = \Yii::$app->request; $response = \Yii::$app->response; $response->format = $response::FORMAT_JSON; - + $model = CreativeRole::findOne($request->post('id')); return [ - 'answer' => $this->renderPartial('_update_form', ['model' => $model]) + 'answer' => $this->renderPartial('_update_form', [ 'model' => $model ]), ]; } diff --git a/frontend/models/CreativeRole.php b/frontend/models/CreativeRole.php index df97526..6f8d332 100755 --- a/frontend/models/CreativeRole.php +++ b/frontend/models/CreativeRole.php @@ -35,6 +35,10 @@ { return [ [ + ['user_id'], + 'required', + ], + [ [ 'intellectual_property_id', 'user_id', diff --git a/frontend/views/cabinet/index.php b/frontend/views/cabinet/index.php index 736299f..5b1201f 100755 --- a/frontend/views/cabinet/index.php +++ b/frontend/views/cabinet/index.php @@ -57,8 +57,8 @@ Назва Дата реєстрації Жанр - Роль автора - Процент долі автора + Роль + Процент долі Нараховано К-ть відтворень diff --git a/frontend/views/cabinet/sales.php b/frontend/views/cabinet/sales.php index 854c85d..aeb7a50 100755 --- a/frontend/views/cabinet/sales.php +++ b/frontend/views/cabinet/sales.php @@ -1,6 +1,8 @@ -
-
- [ - 'class' => 'pjax_container forms-cabinet forms-3', - ], - ] - ); - ?> -
Продаж ОІВ
- 'property-form', - 'action' => \Yii::$app->request->url, - ] - ); - ?> -
+
+
field( - $property, - 'title', + Pjax::begin( [ 'options' => [ - 'class' => 'input-wrapp-757', - 'style' => 'margin-right: 40px;', + 'class' => 'pjax_container forms-cabinet forms-3', ], ] - ) - ->textarea( - [ - 'cols' => 30, - 'rows' => 10, - ] - ); - echo $form->field( - $property, - 'creation_date', + ); + ?> +
Продаж ОІВ
+ [ - 'class' => 'input-wrapp-130', - ], + 'id' => 'property-form', + 'action' => \Yii::$app->request->url, ] - ) - ->textInput( - [ - 'class' => '_datepicer', - ] - ); + ); ?> -
+
field( $property, - 'code', + 'title', [ 'options' => [ - 'class' => 'input-wrapp-320', - ], - ] - ) - ->textInput(); - ?> -
-
- field( - $property, - 'genre', - [ - 'options' => [ - 'class' => 'input-wrapp-320', + 'class' => 'input-wrapp-757', + 'style' => 'margin-right: 40px;', ], ] ) - ->textInput(); - ?> -
-
- textarea( + [ + 'cols' => 30, + 'rows' => 10, + ] + ); echo $form->field( $property, - 'registration_date', + 'creation_date', [ 'options' => [ - 'class' => 'input-wrapp-320', + 'class' => 'input-wrapp-130', ], ] ) @@ -110,166 +67,246 @@ ] ); ?> +
+ field( + $property, + 'code', + [ + 'options' => [ + 'class' => 'input-wrapp-320', + ], + ] + ) + ->textInput(); + ?> +
+
+ field( + $property, + 'genre', + [ + 'options' => [ + 'class' => 'input-wrapp-320', + ], + ] + ) + ->textInput(); + ?> +
+
+ field( + $property, + 'registration_date', + [ + 'options' => [ + 'class' => 'input-wrapp-320', + ], + ] + ) + ->textInput( + [ + 'class' => '_datepicer', + ] + ); + ?> +
+
+ field( + $property, + 'contract', + [ + 'options' => [ + 'class' => 'input-wrapp-320', + 'style' => 'margin-right: 40px;', + ], + ] + ) + ->textInput(); + echo $form->field( + $property, + 'type', + [ + 'options' => [ + 'class' => 'input-wrapp-320', + ], + ] + ) + ->textInput(); + ?> +
+
-
+ + isNewRecord) { + ?> +
+ 'button', + 'class' => 'add-role-button', + 'data-toggle' => 'modal', + 'data-target' => '#add-role-modal', + ] + ) ?> +
+ +
+
+
+ 'roles-table', + ] + ); + ?> + + + + + + + + + + + + + + + + + + + + + +
Творча рольПІБДоля %КодIPIТовариство
title ?>part ?>code ?>iri ?>society ?> + +
+ +
+
+
+ + +
field( - $property, - 'contract', - [ - 'options' => [ - 'class' => 'input-wrapp-320', - 'style' => 'margin-right: 40px;', - ], - ] - ) - ->textInput(); - echo $form->field( - $property, - 'type', - [ - 'options' => [ - 'class' => 'input-wrapp-320', - ], - ] - ) - ->textInput(); + echo Html::submitButton('зберегти'); ?>
- -
- -
- 'button', - 'class' => 'add-role-button', - 'data-toggle' => 'modal', - 'data-target' => '#add-role-modal', - ] - ) ?> -
- -
-
-
- 'roles-table', - ]); - ?> - - - - - - - - - - - - - - - - - - - - - -
Творча рольПІБДоля %КодIPIТовариство
title ?>part ?>code ?>iri ?>society ?> -
- -
-
-
- -
-
-
- - - - - - - \ No newline at end of file + } +?> \ No newline at end of file -- libgit2 0.21.4