diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php index 652f584..cc21ddd 100755 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php @@ -87,7 +87,11 @@ if ($id) { $property = $this->findProperty($id); } else { - $property = new IntellectualProperty(); + $property = new IntellectualProperty( + [ + 'user_id' => \Yii::$app->user->id, + ] + ); $newRecord = true; } if ($property->load(\Yii::$app->request->post()) && $property->save()) { @@ -387,7 +391,14 @@ public function findProperty($id) { - $model = IntellectualProperty::findOne($id); + $model = IntellectualProperty::find() + ->where( + [ + 'id' => $id, + 'user_id' => \Yii::$app->user->id, + ] + ) + ->one(); if (empty( $model )) { throw new NotFoundHttpException(); } diff --git a/frontend/models/IntellectualProperty.php b/frontend/models/IntellectualProperty.php index b1d4b33..b06b513 100755 --- a/frontend/models/IntellectualProperty.php +++ b/frontend/models/IntellectualProperty.php @@ -17,6 +17,7 @@ * @property string $contract * @property string $type * @property CreativeRole[] $creativeRoles + * @property CreativeRole $creativeRole * @property User $user * @property Report[] $reports */ @@ -93,6 +94,12 @@ return $this->hasMany(CreativeRole::className(), [ 'intellectual_property_id' => 'id' ]); } + public function getCreativeRole() + { + return $this->hasOne(CreativeRole::className(), [ 'intellectual_property_id' => 'id' ]) + ->where([ 'user_id' => \Yii::$app->user->id ]); + } + /** * @return \yii\db\ActiveQuery */ diff --git a/frontend/views/cabinet/index.php b/frontend/views/cabinet/index.php index 5b1201f..0bbe0d7 100755 --- a/frontend/views/cabinet/index.php +++ b/frontend/views/cabinet/index.php @@ -7,6 +7,7 @@ * @var IntellectualProperty[] $table */ + use common\models\User; use frontend\models\UserData; use frontend\models\UserPassport; use frontend\models\IntellectualProperty; @@ -15,6 +16,10 @@ use yii\widgets\Pjax; $this->title = 'My Yii Application'; + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; ?>
- title, ['sales', 'id' => $row->id])?> + + user_id == $user->id) { + echo Html::a($row->title, ['sales', 'id' => $row->id]); + } else { + echo $row->title; + } + ?> + registration_date ?> genre ?> - author_role ?> - - - + + creativeRole)) { + echo $row->creativeRole->title; + } elseif($user->isAdmin()) { + echo '-'; + } else { + echo 'У Вас немає ролі в даному ОІВ'; + } + ?> + + + creativeRole)) { + echo $row->creativeRole->part.'%'; + } else { + echo '-'; + } + ?> + + + creativeRole)) { + $sum = 0; + foreach ($row->reports as $report) { + $sum += $report->sum; + } + echo ($sum * $row->creativeRole->part / 100); + unset($sum); + } else { + echo '-'; + } + ?> + + + reports as $report) { + $sum += $report->count; + } + echo $sum; + unset($sum); + ?> +
п/п Назва використаного твору - Виконавець — П.І.Б. виконавця (співвиконавців) або назва колективу виконавців Автор музики (П.І.Б.) Автор тексту (П.І.Б.) Тривалість звучання
(год.:хвил.: сек.)
0:00:00 -- libgit2 0.21.4