Commit 7af4d34d31a04e8a9fc07f74bab85b69f6f60d7d

Authored by Alexey Boroda
1 parent 669a8f62

-Kind of ready

frontend/controllers/CabinetController.php
... ... @@ -9,6 +9,7 @@
9 9 use frontend\models\UserPassport;
10 10 use yii\filters\AccessControl;
11 11 use yii\filters\VerbFilter;
  12 + use yii\helpers\VarDumper;
12 13 use yii\web\Controller;
13 14 use yii\web\NotFoundHttpException;
14 15  
... ... @@ -144,9 +145,20 @@
144 145  
145 146 public function actionArrivals()
146 147 {
147   - $reports = Report::find()
148   - ->with('intellectualProperty')
149   - ->all();
  148 + /**
  149 + * @var User $user
  150 + */
  151 + $user = \Yii::$app->user->identity;
  152 + if ($user->isAdmin()) {
  153 + $reports = Report::find()
  154 + ->with('intellectualProperty')
  155 + ->all();
  156 + } else {
  157 + $reports = Report::find()
  158 + ->joinWith('intellectualProperty.creativeRoles')
  159 + ->where([ 'creative_role.user_id' => $user->id ])
  160 + ->all();
  161 + }
150 162 return $this->render(
151 163 'arrivals',
152 164 [
... ... @@ -157,8 +169,20 @@
157 169  
158 170 public function actionNotifications()
159 171 {
160   - $table = Report::find()
161   - ->all();
  172 + /**
  173 + * @var User $user
  174 + */
  175 + $user = \Yii::$app->user->identity;
  176 + if ($user->isAdmin()) {
  177 + $table = Report::find()
  178 + ->with('intellectualProperty')
  179 + ->all();
  180 + } else {
  181 + $table = Report::find()
  182 + ->joinWith('intellectualProperty.creativeRoles')
  183 + ->where([ 'creative_role.user_id' => $user->id ])
  184 + ->all();
  185 + }
162 186 return $this->render(
163 187 'notifications',
164 188 [
... ...
frontend/views/cabinet/arrivals.php
1 1 <?php
  2 + use common\models\User;
2 3 use frontend\models\Report;
3 4 use yii\helpers\Html;
4 5 use yii\web\View;
... ... @@ -6,7 +7,9 @@
6 7 /**
7 8 * @var View $this
8 9 * @var Report[] $reports
  10 + * @var User $user
9 11 */
  12 + $user = \Yii::$app->user->identity;
10 13 ?>
11 14 <div class="style cab_content_list">
12 15 <div class="title_forms">Мої надходження</div>
... ... @@ -15,22 +18,25 @@
15 18 <tr>
16 19 <td>№<br/>п/п</td>
17 20 <td>Користувач</td>
18   - <td>Виконавець</td>
19 21 <td>Твір</td>
20 22 <td>Кількість сповіщень</td>
21 23 <td>Перерахована сума</td>
22 24 </tr>
23 25 <?php
24 26 foreach ($reports as $index => $report) {
  27 + if ($user->isAdmin()) {
  28 + $sum = $report->sum;
  29 + } else {
  30 + $sum = $report->sum * $report->intellectualProperty->creativeRoles[0]->part /100;
  31 + }
25 32 ?>
26 33 <tr>
27 34 <?php
28 35 echo Html::tag('td', ++$index);
29 36 echo Html::tag('td', $report->user);
30   - echo Html::tag('td', $report->artist);
31 37 echo Html::tag('td', $report->intellectualProperty->title);
32 38 echo Html::tag('td', $report->count);
33   - echo Html::tag('td', $report->sum);
  39 + echo Html::tag('td', $sum);
34 40 ?>
35 41 </tr>
36 42 <?php
... ...
frontend/views/cabinet/notifications.php
1 1 <?php
  2 + use common\models\User;
2 3 use frontend\models\Report;
3 4 use yii\web\View;
4 5  
5 6 /**
6 7 * @var View $this
7 8 * @var Report[] $table
  9 + * @var User $user
8 10 */
  11 + $user = \Yii::$app->user->identity;
9 12 ?>
10 13 <div class="style cab_content_list">
11 14 <div class="cab_content_list-dropdown">
... ... @@ -16,7 +19,6 @@
16 19 <tr>
17 20 <td>№<br/>п/п</td>
18 21 <td>Назва використаного твору</td>
19   - <td>Виконавець — П.І.Б. виконавця (співвиконавців) або назва колективу виконавців</td>
20 22 <td>Автор музики (П.І.Б.)</td>
21 23 <td>Автор тексту (П.І.Б.)</td>
22 24 <td width="150">Тривалість звучання<br/> (год.:хвил.: сек.)<br/>0:00:00</td>
... ... @@ -31,11 +33,16 @@
31 33 <tr>
32 34 <td><?=$i?></td>
33 35 <td><span class="name-songs"><?=$row->intellectualProperty->title?></span></td>
34   - <td><?=$row->artist?></td>
35 36 <td>-</td>
36 37 <td>-</td>
37 38 <td>—</td>
38   - <td><?=$row->royalty?></td>
  39 + <td><?php
  40 + if ($user->isAdmin()) {
  41 + echo $row->royalty;
  42 + } else {
  43 + echo $row->royalty * $row->intellectualProperty->creativeRoles[0]->part /100;
  44 + }
  45 + ?></td>
39 46 <td><?=$row->count?></td>
40 47 <td>—</td>
41 48 </tr>
... ...
frontend/views/cabinet/users.php
... ... @@ -44,7 +44,6 @@
44 44 <tr>
45 45 <td>№<br/>п/п</td>
46 46 <td>Користувач</td>
47   - <td>Виконавець</td>
48 47 <td>Твір</td>
49 48 <td>Кількість сповіщень</td>
50 49 <td>Перерахована сума</td>
... ... @@ -55,19 +54,23 @@
55 54 </tr>
56 55 <?php
57 56 foreach ($reports as $index => $report) {
  57 + if ($user->isAdmin()) {
  58 + $sum = $report->sum;
  59 + } else {
  60 + $sum = $report->sum * $report->intellectualProperty->creativeRoles[0]->part / 100;
  61 + }
58 62 ?>
59 63 <tr>
60 64 <?php
61 65 echo Html::tag('td', ++$index);
62 66 echo Html::tag('td', $report->user);
63   - echo Html::tag('td', '');
64 67 echo Html::tag('td', $report->intellectualProperty->title);
65 68 echo Html::tag('td', $report->count);
66   - echo Html::tag('td', $report->sum);
67   - echo Html::tag('td', $report->sum*0.2);
68   - echo Html::tag('td', $report->sum*0.8);
69   - echo Html::tag('td', $report->sum*0.8*0.195);
70   - echo Html::tag('td', $report->sum*0.8*0.805);
  69 + echo Html::tag('td', $sum);
  70 + echo Html::tag('td', $sum*0.2);
  71 + echo Html::tag('td', $sum*0.8);
  72 + echo Html::tag('td', $sum*0.8*0.195);
  73 + echo Html::tag('td', $sum*0.8*0.805);
71 74 ?>
72 75 </tr>
73 76 <?php
... ...