From 7af4d34d31a04e8a9fc07f74bab85b69f6f60d7d Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 30 Dec 2016 14:56:32 +0200 Subject: [PATCH] -Kind of ready --- frontend/controllers/CabinetController.php | 34 +++++++++++++++++++++++++++++----- frontend/views/cabinet/arrivals.php | 12 +++++++++--- frontend/views/cabinet/notifications.php | 13 ++++++++++--- frontend/views/cabinet/users.php | 17 ++++++++++------- 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php index a978cba..9f5b641 100755 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php @@ -9,6 +9,7 @@ use frontend\models\UserPassport; use yii\filters\AccessControl; use yii\filters\VerbFilter; + use yii\helpers\VarDumper; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -144,9 +145,20 @@ public function actionArrivals() { - $reports = Report::find() - ->with('intellectualProperty') - ->all(); + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + if ($user->isAdmin()) { + $reports = Report::find() + ->with('intellectualProperty') + ->all(); + } else { + $reports = Report::find() + ->joinWith('intellectualProperty.creativeRoles') + ->where([ 'creative_role.user_id' => $user->id ]) + ->all(); + } return $this->render( 'arrivals', [ @@ -157,8 +169,20 @@ public function actionNotifications() { - $table = Report::find() - ->all(); + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + if ($user->isAdmin()) { + $table = Report::find() + ->with('intellectualProperty') + ->all(); + } else { + $table = Report::find() + ->joinWith('intellectualProperty.creativeRoles') + ->where([ 'creative_role.user_id' => $user->id ]) + ->all(); + } return $this->render( 'notifications', [ diff --git a/frontend/views/cabinet/arrivals.php b/frontend/views/cabinet/arrivals.php index bda8813..e77392f 100755 --- a/frontend/views/cabinet/arrivals.php +++ b/frontend/views/cabinet/arrivals.php @@ -1,4 +1,5 @@ user->identity; ?>
Мої надходження
@@ -15,22 +18,25 @@ №
п/п Користувач - Виконавець Твір Кількість сповіщень Перерахована сума $report) { + if ($user->isAdmin()) { + $sum = $report->sum; + } else { + $sum = $report->sum * $report->intellectualProperty->creativeRoles[0]->part /100; + } ?> user); - echo Html::tag('td', $report->artist); echo Html::tag('td', $report->intellectualProperty->title); echo Html::tag('td', $report->count); - echo Html::tag('td', $report->sum); + echo Html::tag('td', $sum); ?> user->identity; ?>
@@ -16,7 +19,6 @@ №
п/п Назва використаного твору - Виконавець — П.І.Б. виконавця (співвиконавців) або назва колективу виконавців Автор музики (П.І.Б.) Автор тексту (П.І.Б.) Тривалість звучання
(год.:хвил.: сек.)
0:00:00 @@ -31,11 +33,16 @@ intellectualProperty->title?> - artist?> - - — - royalty?> + isAdmin()) { + echo $row->royalty; + } else { + echo $row->royalty * $row->intellectualProperty->creativeRoles[0]->part /100; + } + ?> count?> — diff --git a/frontend/views/cabinet/users.php b/frontend/views/cabinet/users.php index 4a7b3a5..9d8ff2d 100755 --- a/frontend/views/cabinet/users.php +++ b/frontend/views/cabinet/users.php @@ -44,7 +44,6 @@ №
п/п Користувач - Виконавець Твір Кількість сповіщень Перерахована сума @@ -55,19 +54,23 @@ $report) { + if ($user->isAdmin()) { + $sum = $report->sum; + } else { + $sum = $report->sum * $report->intellectualProperty->creativeRoles[0]->part / 100; + } ?> user); - echo Html::tag('td', ''); echo Html::tag('td', $report->intellectualProperty->title); echo Html::tag('td', $report->count); - echo Html::tag('td', $report->sum); - echo Html::tag('td', $report->sum*0.2); - echo Html::tag('td', $report->sum*0.8); - echo Html::tag('td', $report->sum*0.8*0.195); - echo Html::tag('td', $report->sum*0.8*0.805); + echo Html::tag('td', $sum); + echo Html::tag('td', $sum*0.2); + echo Html::tag('td', $sum*0.8); + echo Html::tag('td', $sum*0.8*0.195); + echo Html::tag('td', $sum*0.8*0.805); ?>