Commit f9e2ff5ecca46c118b45a15f70d3b304f909ff0e

Authored by Yarik
2 parents 885e52f4 7af4d34d

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	frontend/controllers/CabinetController.php
frontend/controllers/CabinetController.php
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 use frontend\models\UserPassport; 9 use frontend\models\UserPassport;
10 use yii\filters\AccessControl; 10 use yii\filters\AccessControl;
11 use yii\filters\VerbFilter; 11 use yii\filters\VerbFilter;
  12 + use yii\helpers\VarDumper;
12 use yii\web\Controller; 13 use yii\web\Controller;
13 use yii\web\NotFoundHttpException; 14 use yii\web\NotFoundHttpException;
14 15
@@ -81,7 +82,7 @@ @@ -81,7 +82,7 @@
81 ); 82 );
82 } 83 }
83 84
84 - public function actionSales($id = null) 85 + public function actionSales($id = NULL)
85 { 86 {
86 $newRecord = false; 87 $newRecord = false;
87 if ($id) { 88 if ($id) {
@@ -131,11 +132,12 @@ @@ -131,11 +132,12 @@
131 132
132 public function actionList() 133 public function actionList()
133 { 134 {
134 - $table = IntellectualProperty::find()// ->where(  
135 - // [  
136 - // 'user_id' => \Yii::$app->user->identity->id,  
137 - // ]  
138 - // ) 135 + $table = IntellectualProperty::find()
  136 +// ->where(
  137 +// [
  138 +// 'user_id' => \Yii::$app->user->identity->id,
  139 +// ]
  140 +// )
139 ->all(); 141 ->all();
140 return $this->render( 142 return $this->render(
141 'list', 143 'list',
@@ -147,9 +149,20 @@ @@ -147,9 +149,20 @@
147 149
148 public function actionArrivals() 150 public function actionArrivals()
149 { 151 {
150 - $reports = Report::find()  
151 - ->with('intellectualProperty')  
152 - ->all(); 152 + /**
  153 + * @var User $user
  154 + */
  155 + $user = \Yii::$app->user->identity;
  156 + if ($user->isAdmin()) {
  157 + $reports = Report::find()
  158 + ->with('intellectualProperty')
  159 + ->all();
  160 + } else {
  161 + $reports = Report::find()
  162 + ->joinWith('intellectualProperty.creativeRoles')
  163 + ->where([ 'creative_role.user_id' => $user->id ])
  164 + ->all();
  165 + }
153 return $this->render( 166 return $this->render(
154 'arrivals', 167 'arrivals',
155 [ 168 [
@@ -160,8 +173,20 @@ @@ -160,8 +173,20 @@
160 173
161 public function actionNotifications() 174 public function actionNotifications()
162 { 175 {
163 - $table = Report::find()  
164 - ->all(); 176 + /**
  177 + * @var User $user
  178 + */
  179 + $user = \Yii::$app->user->identity;
  180 + if ($user->isAdmin()) {
  181 + $table = Report::find()
  182 + ->with('intellectualProperty')
  183 + ->all();
  184 + } else {
  185 + $table = Report::find()
  186 + ->joinWith('intellectualProperty.creativeRoles')
  187 + ->where([ 'creative_role.user_id' => $user->id ])
  188 + ->all();
  189 + }
165 return $this->render( 190 return $this->render(
166 'notifications', 191 'notifications',
167 [ 192 [
@@ -172,9 +197,21 @@ @@ -172,9 +197,21 @@
172 197
173 public function actionUsers() 198 public function actionUsers()
174 { 199 {
175 - $reports = Report::find()  
176 - ->with('intellectualProperty')  
177 - ->all(); 200 + /**
  201 + * @var User $user
  202 + */
  203 + $user = \Yii::$app->user->identity;
  204 + if ($user->isAdmin()) {
  205 + $reports = Report::find()
  206 + ->with('intellectualProperty')
  207 + ->all();
  208 + } else {
  209 + $reports = Report::find()
  210 + ->joinWith('intellectualProperty.creativeRoles')
  211 + ->where([ 'creative_role.user_id' => $user->id ])
  212 + ->all();
  213 + }
  214 +
178 return $this->render( 215 return $this->render(
179 'users', 216 'users',
180 [ 217 [
@@ -286,7 +323,7 @@ @@ -286,7 +323,7 @@
286 $response = \Yii::$app->response; 323 $response = \Yii::$app->response;
287 $response->format = $response::FORMAT_JSON; 324 $response->format = $response::FORMAT_JSON;
288 325
289 - if (!empty( $request->post('id') )) { 326 + if (!empty($request->post('id'))) {
290 $role = IntellectualProperty::findOne($request->post('id')); 327 $role = IntellectualProperty::findOne($request->post('id'));
291 if ($role->delete()) { 328 if ($role->delete()) {
292 return [ 329 return [
@@ -368,7 +405,7 @@ @@ -368,7 +405,7 @@
368 $response = \Yii::$app->response; 405 $response = \Yii::$app->response;
369 $response->format = $response::FORMAT_JSON; 406 $response->format = $response::FORMAT_JSON;
370 407
371 - if (!empty( $request->post('id') )) { 408 + if (!empty($request->post('id'))) {
372 $role = CreativeRole::findOne($request->post('id')); 409 $role = CreativeRole::findOne($request->post('id'));
373 if ($role->delete()) { 410 if ($role->delete()) {
374 return [ 411 return [
frontend/views/cabinet/arrivals.php
1 <?php 1 <?php
  2 + use common\models\User;
2 use frontend\models\Report; 3 use frontend\models\Report;
3 use yii\helpers\Html; 4 use yii\helpers\Html;
4 use yii\web\View; 5 use yii\web\View;
@@ -6,7 +7,9 @@ @@ -6,7 +7,9 @@
6 /** 7 /**
7 * @var View $this 8 * @var View $this
8 * @var Report[] $reports 9 * @var Report[] $reports
  10 + * @var User $user
9 */ 11 */
  12 + $user = \Yii::$app->user->identity;
10 ?> 13 ?>
11 <div class="style cab_content_list"> 14 <div class="style cab_content_list">
12 <div class="title_forms">Мої надходження</div> 15 <div class="title_forms">Мої надходження</div>
@@ -15,22 +18,25 @@ @@ -15,22 +18,25 @@
15 <tr> 18 <tr>
16 <td>№<br/>п/п</td> 19 <td>№<br/>п/п</td>
17 <td>Користувач</td> 20 <td>Користувач</td>
18 - <td>Виконавець</td>  
19 <td>Твір</td> 21 <td>Твір</td>
20 <td>Кількість сповіщень</td> 22 <td>Кількість сповіщень</td>
21 <td>Перерахована сума</td> 23 <td>Перерахована сума</td>
22 </tr> 24 </tr>
23 <?php 25 <?php
24 foreach ($reports as $index => $report) { 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 <tr> 33 <tr>
27 <?php 34 <?php
28 echo Html::tag('td', ++$index); 35 echo Html::tag('td', ++$index);
29 echo Html::tag('td', $report->user); 36 echo Html::tag('td', $report->user);
30 - echo Html::tag('td', $report->artist);  
31 echo Html::tag('td', $report->intellectualProperty->title); 37 echo Html::tag('td', $report->intellectualProperty->title);
32 echo Html::tag('td', $report->count); 38 echo Html::tag('td', $report->count);
33 - echo Html::tag('td', $report->sum); 39 + echo Html::tag('td', $sum);
34 ?> 40 ?>
35 </tr> 41 </tr>
36 <?php 42 <?php
frontend/views/cabinet/notifications.php
1 <?php 1 <?php
  2 + use common\models\User;
2 use frontend\models\Report; 3 use frontend\models\Report;
3 use yii\web\View; 4 use yii\web\View;
4 5
5 /** 6 /**
6 * @var View $this 7 * @var View $this
7 * @var Report[] $table 8 * @var Report[] $table
  9 + * @var User $user
8 */ 10 */
  11 + $user = \Yii::$app->user->identity;
9 ?> 12 ?>
10 <div class="style cab_content_list"> 13 <div class="style cab_content_list">
11 <div class="cab_content_list-dropdown"> 14 <div class="cab_content_list-dropdown">
@@ -30,11 +33,16 @@ @@ -30,11 +33,16 @@
30 <tr> 33 <tr>
31 <td><?=$i?></td> 34 <td><?=$i?></td>
32 <td><span class="name-songs"><?=$row->intellectualProperty->title?></span></td> 35 <td><span class="name-songs"><?=$row->intellectualProperty->title?></span></td>
33 - <td><?=$row->artist?></td>  
34 <td>-</td> 36 <td>-</td>
35 <td>-</td> 37 <td>-</td>
36 <td>—</td> 38 <td>—</td>
37 - <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>
38 <td><?=$row->count?></td> 46 <td><?=$row->count?></td>
39 <td>—</td> 47 <td>—</td>
40 </tr> 48 </tr>
frontend/views/cabinet/users.php
1 <?php 1 <?php
  2 + use common\models\User;
2 use frontend\models\IntellectualProperty; 3 use frontend\models\IntellectualProperty;
3 use frontend\models\Report; 4 use frontend\models\Report;
4 use yii\helpers\Html; 5 use yii\helpers\Html;
@@ -9,14 +10,17 @@ @@ -9,14 +10,17 @@
9 /** 10 /**
10 * @var View $this 11 * @var View $this
11 * @var Report[] $reports 12 * @var Report[] $reports
  13 + * @var User $user
12 */ 14 */
  15 +
  16 + $user = \Yii::$app->user->identity;
13 ?> 17 ?>
14 <div class="style cab_content_list"> 18 <div class="style cab_content_list">
15 <div class="cab_content_list-dropdown"> 19 <div class="cab_content_list-dropdown">
16 <div class="style table-forms tables-1"> 20 <div class="style table-forms tables-1">
17 <div class="title_forms">Звіт про загальну суму винагороди (у розрізі користувачів)</div> 21 <div class="title_forms">Звіт про загальну суму винагороди (у розрізі користувачів)</div>
18 <div class="btn-submit-blue"> 22 <div class="btn-submit-blue">
19 - <?php echo Html::button( 23 + <?php if ($user->isAdmin()) echo Html::button(
20 'Добавить', 24 'Добавить',
21 [ 25 [
22 'type' => 'button', 26 'type' => 'button',
@@ -40,7 +44,6 @@ @@ -40,7 +44,6 @@
40 <tr> 44 <tr>
41 <td>№<br/>п/п</td> 45 <td>№<br/>п/п</td>
42 <td>Користувач</td> 46 <td>Користувач</td>
43 - <td>Виконавець</td>  
44 <td>Твір</td> 47 <td>Твір</td>
45 <td>Кількість сповіщень</td> 48 <td>Кількість сповіщень</td>
46 <td>Перерахована сума</td> 49 <td>Перерахована сума</td>
@@ -51,19 +54,23 @@ @@ -51,19 +54,23 @@
51 </tr> 54 </tr>
52 <?php 55 <?php
53 foreach ($reports as $index => $report) { 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 + }
54 ?> 62 ?>
55 <tr> 63 <tr>
56 <?php 64 <?php
57 echo Html::tag('td', ++$index); 65 echo Html::tag('td', ++$index);
58 echo Html::tag('td', $report->user); 66 echo Html::tag('td', $report->user);
59 - echo Html::tag('td', $report->artist);  
60 echo Html::tag('td', $report->intellectualProperty->title); 67 echo Html::tag('td', $report->intellectualProperty->title);
61 echo Html::tag('td', $report->count); 68 echo Html::tag('td', $report->count);
62 - echo Html::tag('td', $report->sum);  
63 - echo Html::tag('td', $report->sum*0.2);  
64 - echo Html::tag('td', $report->sum*0.8);  
65 - echo Html::tag('td', $report->sum*0.8*0.195);  
66 - 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);
67 ?> 74 ?>
68 </tr> 75 </tr>
69 <?php 76 <?php
@@ -98,7 +105,7 @@ @@ -98,7 +105,7 @@
98 <?php 105 <?php
99 echo $form->field($report, 'user') 106 echo $form->field($report, 'user')
100 ->textInput(); 107 ->textInput();
101 - echo $form->field($report, 'artist'); 108 +// echo $form->field($report, 'artist');
102 echo $form->field($report, 'intellectual_property_id') 109 echo $form->field($report, 'intellectual_property_id')
103 ->dropDownList( 110 ->dropDownList(
104 IntellectualProperty::find() 111 IntellectualProperty::find()