Commit 3533e4e91e4f5a648dd185874da489425ae82f6c

Authored by Yarik
1 parent 26726891

Forms

console/migrations/m161228_100649_add_report_columns.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +class m161228_100649_add_report_columns extends Migration
  6 +{
  7 + public function up()
  8 + {
  9 + $this->addColumn('report', 'user', $this->string());
  10 + $this->addColumn('report', 'sum', $this->decimal());
  11 + }
  12 +
  13 + public function down()
  14 + {
  15 + $this->dropColumn('report', 'user');
  16 + $this->dropColumn('report', 'sum');
  17 + }
  18 +}
console/migrations/m161228_105659_alter_intellectual_columns.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +class m161228_105659_alter_intellectual_columns extends Migration
  6 +{
  7 + public function up()
  8 + {
  9 + $this->alterColumn('intellectual_property', 'percent', 'numeric(10,0) USING (percent::float)');
  10 + $this->alterColumn('intellectual_property', 'calculated', 'numeric(10,0) USING (percent::float)');
  11 + }
  12 +
  13 + public function down()
  14 + {
  15 +
  16 + }
  17 +}
frontend/controllers/CabinetController.php
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 use common\models\User; 4 use common\models\User;
5 use frontend\models\CreativeRole; 5 use frontend\models\CreativeRole;
6 use frontend\models\IntellectualProperty; 6 use frontend\models\IntellectualProperty;
  7 + use frontend\models\Report;
7 use frontend\models\UserData; 8 use frontend\models\UserData;
8 use frontend\models\UserPassport; 9 use frontend\models\UserPassport;
9 use yii\filters\VerbFilter; 10 use yii\filters\VerbFilter;
@@ -71,7 +72,7 @@ @@ -71,7 +72,7 @@
71 ); 72 );
72 } 73 }
73 74
74 - public function actionSales($id = NULL) 75 + public function actionSales($id = null)
75 { 76 {
76 $newRecord = false; 77 $newRecord = false;
77 if ($id) { 78 if ($id) {
@@ -134,7 +135,15 @@ @@ -134,7 +135,15 @@
134 135
135 public function actionArrivals() 136 public function actionArrivals()
136 { 137 {
137 - return $this->render('arrivals'); 138 + $reports = Report::find()
  139 + ->with('intellectualProperty')
  140 + ->all();
  141 + return $this->render(
  142 + 'arrivals',
  143 + [
  144 + 'reports' => $reports,
  145 + ]
  146 + );
138 } 147 }
139 148
140 public function actionNotifications() 149 public function actionNotifications()
@@ -144,7 +153,37 @@ @@ -144,7 +153,37 @@
144 153
145 public function actionUsers() 154 public function actionUsers()
146 { 155 {
147 - return $this->render('users'); 156 + $reports = Report::find()
  157 + ->with('intellectualProperty')
  158 + ->all();
  159 + return $this->render(
  160 + 'users',
  161 + [
  162 + 'reports' => $reports,
  163 + ]
  164 + );
  165 + }
  166 +
  167 + public function actionUsersAdd()
  168 + {
  169 + $request = \Yii::$app->request;
  170 + $response = \Yii::$app->response;
  171 + $response->format = $response::FORMAT_JSON;
  172 + /**
  173 + * @var User $user
  174 + */
  175 + $report = new Report();
  176 + if ($report->load($request->post()) && $report->save()) {
  177 + return [
  178 + 'success' => true,
  179 + 'message' => 'Данные успешно сохранены',
  180 + ];
  181 + } else {
  182 + return [
  183 + 'error' => true,
  184 + 'message' => 'Ошибка сохранения данных',
  185 + ];
  186 + }
148 } 187 }
149 188
150 public function actionPersonal() 189 public function actionPersonal()
@@ -221,14 +260,14 @@ @@ -221,14 +260,14 @@
221 ]; 260 ];
222 } 261 }
223 } 262 }
224 - 263 +
225 public function actionDeleteIntProperty() 264 public function actionDeleteIntProperty()
226 { 265 {
227 $request = \Yii::$app->request; 266 $request = \Yii::$app->request;
228 $response = \Yii::$app->response; 267 $response = \Yii::$app->response;
229 $response->format = $response::FORMAT_JSON; 268 $response->format = $response::FORMAT_JSON;
230 -  
231 - if (!empty($request->post('id'))) { 269 +
  270 + if (!empty( $request->post('id') )) {
232 $role = IntellectualProperty::findOne($request->post('id')); 271 $role = IntellectualProperty::findOne($request->post('id'));
233 if ($role->delete()) { 272 if ($role->delete()) {
234 return [ 273 return [
@@ -276,7 +315,7 @@ @@ -276,7 +315,7 @@
276 $response = \Yii::$app->response; 315 $response = \Yii::$app->response;
277 $response->format = $response::FORMAT_JSON; 316 $response->format = $response::FORMAT_JSON;
278 317
279 - if (!empty($request->post('id'))) { 318 + if (!empty( $request->post('id') )) {
280 $role = CreativeRole::findOne($request->post('id')); 319 $role = CreativeRole::findOne($request->post('id'));
281 if ($role->delete()) { 320 if ($role->delete()) {
282 return [ 321 return [
@@ -300,7 +339,7 @@ @@ -300,7 +339,7 @@
300 public function findProperty($id) 339 public function findProperty($id)
301 { 340 {
302 $model = IntellectualProperty::findOne($id); 341 $model = IntellectualProperty::findOne($id);
303 - if (empty($model)) { 342 + if (empty( $model )) {
304 throw new NotFoundHttpException(); 343 throw new NotFoundHttpException();
305 } 344 }
306 return $model; 345 return $model;
frontend/models/Report.php
1 <?php 1 <?php
2 -  
3 -namespace frontend\models;  
4 -  
5 -/**  
6 - * This is the model class for table "report".  
7 - *  
8 - * @property integer $id  
9 - * @property integer $intellectual_property_id  
10 - * @property string $title  
11 - * @property string $artist  
12 - * @property string $music_author  
13 - * @property string $text_author  
14 - * @property integer $time  
15 - * @property integer $total_time  
16 - * @property double $royalty  
17 - * @property integer $count  
18 - *  
19 - * @property IntellectualProperty $intellectualProperty  
20 - */  
21 -class Report extends \yii\db\ActiveRecord  
22 -{ 2 +
  3 + namespace frontend\models;
  4 +
23 /** 5 /**
24 - * @inheritdoc 6 + * This is the model class for table "report".
  7 + *
  8 + * @property integer $id
  9 + * @property integer $intellectual_property_id
  10 + * @property string $title
  11 + * @property string $artist
  12 + * @property string $music_author
  13 + * @property string $text_author
  14 + * @property integer $time
  15 + * @property integer $total_time
  16 + * @property double $royalty
  17 + * @property integer $count
  18 + * @property string $user
  19 + * @property float $sum
  20 + * @property IntellectualProperty $intellectualProperty
25 */ 21 */
26 - public static function tableName() 22 + class Report extends \yii\db\ActiveRecord
27 { 23 {
28 - return 'report'; 24 + /**
  25 + * @inheritdoc
  26 + */
  27 + public static function tableName()
  28 + {
  29 + return 'report';
  30 + }
  31 +
  32 + /**
  33 + * @inheritdoc
  34 + */
  35 + public function rules()
  36 + {
  37 + return [
  38 + [
  39 + [
  40 + 'intellectual_property_id',
  41 + 'time',
  42 + 'total_time',
  43 + 'count',
  44 + ],
  45 + 'integer',
  46 + ],
  47 + [
  48 + [
  49 + 'royalty',
  50 + 'sum',
  51 + ],
  52 + 'number',
  53 + ],
  54 + [
  55 + [
  56 + 'title',
  57 + 'artist',
  58 + 'music_author',
  59 + 'text_author',
  60 + 'user',
  61 + ],
  62 + 'string',
  63 + 'max' => 255,
  64 + ],
  65 + [
  66 + [ 'intellectual_property_id' ],
  67 + 'exist',
  68 + 'skipOnError' => true,
  69 + 'targetClass' => IntellectualProperty::className(),
  70 + 'targetAttribute' => [ 'intellectual_property_id' => 'id' ],
  71 + ],
  72 + ];
  73 + }
  74 +
  75 + /**
  76 + * @inheritdoc
  77 + */
  78 + public function attributeLabels()
  79 + {
  80 + return [
  81 + 'id' => 'ID',
  82 + 'intellectual_property_id' => 'Твір',
  83 + 'title' => 'Title',
  84 + 'artist' => 'Виконавець',
  85 + 'music_author' => 'Music Author',
  86 + 'text_author' => 'Text Author',
  87 + 'time' => 'Time',
  88 + 'total_time' => 'Total Time',
  89 + 'royalty' => 'Royalty',
  90 + 'count' => 'Кількість сповіщень',
  91 + 'sum' => 'Перерахована сума',
  92 + 'user' => 'Користувач',
  93 + ];
  94 + }
  95 +
  96 + /**
  97 + * @return \yii\db\ActiveQuery
  98 + */
  99 + public function getIntellectualProperty()
  100 + {
  101 + return $this->hasOne(IntellectualProperty::className(), [ 'id' => 'intellectual_property_id' ]);
  102 + }
  103 +
  104 + public function afterSave($insert, $changedAttributes)
  105 + {
  106 + if (!empty( $property = IntellectualProperty::findOne($this->intellectual_property_id) )) {
  107 + var_dump($property); die();
  108 + $sum = 0;
  109 + foreach ($property->reports as $report) {
  110 + $sum += $report->sum;
  111 + }
  112 + $property->calculated = $property->percent * $sum / 100;
  113 + $property->save(true, [ 'calculated' ]);
  114 + }
  115 + parent::afterSave($insert, $changedAttributes);
  116 + }
29 } 117 }
30 -  
31 - /**  
32 - * @inheritdoc  
33 - */  
34 - public function rules()  
35 - {  
36 - return [  
37 - [['intellectual_property_id', 'time', 'total_time', 'count'], 'integer'],  
38 - [['royalty'], 'number'],  
39 - [['title', 'artist', 'music_author', 'text_author'], 'string', 'max' => 255],  
40 - [['intellectual_property_id'], 'exist', 'skipOnError' => true, 'targetClass' => IntellectualProperty::className(), 'targetAttribute' => ['intellectual_property_id' => 'id']],  
41 - ];  
42 - }  
43 -  
44 - /**  
45 - * @inheritdoc  
46 - */  
47 - public function attributeLabels()  
48 - {  
49 - return [  
50 - 'id' => 'ID',  
51 - 'intellectual_property_id' => 'Intellectual Property ID',  
52 - 'title' => 'Title',  
53 - 'artist' => 'Artist',  
54 - 'music_author' => 'Music Author',  
55 - 'text_author' => 'Text Author',  
56 - 'time' => 'Time',  
57 - 'total_time' => 'Total Time',  
58 - 'royalty' => 'Royalty',  
59 - 'count' => 'Count',  
60 - ];  
61 - }  
62 -  
63 - /**  
64 - * @return \yii\db\ActiveQuery  
65 - */  
66 - public function getIntellectualProperty()  
67 - {  
68 - return $this->hasOne(IntellectualProperty::className(), ['id' => 'intellectual_property_id']);  
69 - }  
70 -}  
frontend/views/cabinet/arrivals.php
1 <?php 1 <?php
  2 + use frontend\models\Report;
  3 + use yii\helpers\Html;
2 use yii\web\View; 4 use yii\web\View;
3 5
4 /** 6 /**
5 - * @var View $this 7 + * @var View $this
  8 + * @var Report[] $reports
6 */ 9 */
7 ?> 10 ?>
8 <div class="style cab_content_list"> 11 <div class="style cab_content_list">
9 <div class="title_forms">Мої надходження</div> 12 <div class="title_forms">Мої надходження</div>
10 <div class="style table-forms-wrapp"> 13 <div class="style table-forms-wrapp">
11 -  
12 <table class="table-1" cellpadding="0" cellspacing="0" border="0"> 14 <table class="table-1" cellpadding="0" cellspacing="0" border="0">
13 <tr> 15 <tr>
14 <td>№<br/>п/п</td> 16 <td>№<br/>п/п</td>
@@ -18,273 +20,22 @@ @@ -18,273 +20,22 @@
18 <td>Кількість сповіщень</td> 20 <td>Кількість сповіщень</td>
19 <td>Перерахована сума</td> 21 <td>Перерахована сума</td>
20 </tr> 22 </tr>
21 -  
22 - <tr>  
23 - <td>1</td>  
24 - <td>Радіо "BOOM"</td>  
25 - <td>Джорж Вашингтон</td>  
26 - <td>Нью-Йорк</td>  
27 - <td>10</td>  
28 - <td>100</td>  
29 - </tr>  
30 - <tr>  
31 - <td>2</td>  
32 - <td>Радіо "MUSOFF"</td>  
33 - <td>Джорж Вашингтон</td>  
34 - <td>Калифорнія</td>  
35 - <td>8</td>  
36 - <td>80</td>  
37 - </tr>  
38 - <tr>  
39 - <td>3</td>  
40 - <td>Радіо "MUSOFF"</td>  
41 - <td>Джорж Вашингтон</td>  
42 - <td>Іллінойс</td>  
43 - <td>6</td>  
44 - <td>60</td>  
45 - </tr>  
46 - <tr>  
47 - <td></td>  
48 - <td></td>  
49 - <td></td>  
50 - <td></td>  
51 - <td></td>  
52 - <td></td>  
53 - </tr>  
54 - <tr>  
55 - <td></td>  
56 - <td></td>  
57 - <td></td>  
58 - <td></td>  
59 - <td></td>  
60 - <td></td>  
61 - </tr>  
62 - <tr>  
63 - <td></td>  
64 - <td></td>  
65 - <td></td>  
66 - <td></td>  
67 - <td></td>  
68 - <td></td>  
69 - </tr>  
70 - <tr>  
71 - <td></td>  
72 - <td></td>  
73 - <td></td>  
74 - <td></td>  
75 - <td></td>  
76 - <td></td>  
77 - </tr>  
78 - <tr>  
79 - <td></td>  
80 - <td></td>  
81 - <td></td>  
82 - <td></td>  
83 - <td></td>  
84 - <td></td>  
85 - </tr>  
86 - <tr>  
87 - <td></td>  
88 - <td></td>  
89 - <td></td>  
90 - <td></td>  
91 - <td></td>  
92 - <td></td>  
93 - </tr>  
94 - <tr>  
95 - <td></td>  
96 - <td></td>  
97 - <td></td>  
98 - <td></td>  
99 - <td></td>  
100 - <td></td>  
101 - </tr>  
102 - <tr>  
103 - <td></td>  
104 - <td></td>  
105 - <td></td>  
106 - <td></td>  
107 - <td></td>  
108 - <td></td>  
109 - </tr>  
110 - <tr>  
111 - <td></td>  
112 - <td></td>  
113 - <td></td>  
114 - <td></td>  
115 - <td></td>  
116 - <td></td>  
117 - </tr>  
118 - <tr>  
119 - <td></td>  
120 - <td></td>  
121 - <td></td>  
122 - <td></td>  
123 - <td></td>  
124 - <td></td>  
125 - </tr>  
126 - <tr>  
127 - <td></td>  
128 - <td></td>  
129 - <td></td>  
130 - <td></td>  
131 - <td></td>  
132 - <td></td>  
133 - </tr> 23 + <?php
  24 + foreach ($reports as $index => $report) {
  25 + ?>
  26 + <tr>
  27 + <?php
  28 + echo Html::tag('td', ++$index);
  29 + echo Html::tag('td', $report->user);
  30 + echo Html::tag('td', $report->artist);
  31 + echo Html::tag('td', $report->intellectualProperty->title);
  32 + echo Html::tag('td', $report->count);
  33 + echo Html::tag('td', $report->sum);
  34 + ?>
  35 + </tr>
  36 + <?php
  37 + }
  38 + ?>
134 </table> 39 </table>
135 -  
136 - <!--<table class="table-1" cellpadding="0" cellspacing="0" border="0">-->  
137 - <!--<tr>-->  
138 - <!--<td>№<br />п/п</td>-->  
139 - <!--<td>Назва використаного твору</td>-->  
140 - <!--<td>Виконавець — П.І.Б. виконавця (співвиконавців) або назва колективу виконавців</td>-->  
141 - <!--<td>Автор музики (П.І.Б.)</td>-->  
142 - <!--<td>Автор тексту (П.І.Б.)</td>-->  
143 - <!--<td width="150">Тривалість звучання<br /> (год.:хвил.: сек.)<br />0:00:00</td>-->  
144 - <!--<td>Кількість публічних сповіщень твору</td>-->  
145 - <!--<td>Загальна Тривалість звучання твору<br />(год.:хвил.: сек.) 0:00:00</td>-->  
146 - <!--</tr>-->  
147 -  
148 - <!--<tr>-->  
149 - <!--<td>1</td>-->  
150 - <!--<td><span class="name-songs">ЕЩЁ НЕ ВЕЧЕР</span></td>-->  
151 - <!--<td>Лайма Вайкуле</td>-->  
152 - <!--<td>Р.Паулс</td>-->  
153 - <!--<td>И.Р. Резник</td>-->  
154 - <!--<td>—</td>-->  
155 - <!--<td>1</td>-->  
156 - <!--<td>—</td>-->  
157 - <!--</tr>-->  
158 - <!--<tr>-->  
159 - <!--<td>2</td>-->  
160 - <!--<td><span class="name-songs">ЛИСТЬЯ ЖЁЛТЫЕ</span></td>-->  
161 - <!--<td>Лайма Вайкуле</td>-->  
162 - <!--<td>Р.Паулс</td>-->  
163 - <!--<td>Я. Петерс / И.Д. Шаферан</td>-->  
164 - <!--<td>—</td>-->  
165 - <!--<td>1</td>-->  
166 - <!--<td>—</td>-->  
167 - <!--</tr>-->  
168 - <!--<tr>-->  
169 - <!--<td>3</td>-->  
170 - <!--<td><span class="name-songs">ОГОНЬКИ</span></td>-->  
171 - <!--<td>Лайма Вайкуле</td>-->  
172 - <!--<td>Р.Паулс</td>-->  
173 - <!--<td>В.Сєрова</td>-->  
174 - <!--<td>—</td>-->  
175 - <!--<td>1</td>-->  
176 - <!--<td>—</td>-->  
177 - <!--</tr>-->  
178 - <!--<tr>-->  
179 - <!--<td></td>-->  
180 - <!--<td></td>-->  
181 - <!--<td></td>-->  
182 - <!--<td></td>-->  
183 - <!--<td></td>-->  
184 - <!--<td></td>-->  
185 - <!--<td></td>-->  
186 - <!--<td></td>-->  
187 - <!--</tr>-->  
188 - <!--<tr>-->  
189 - <!--<td></td>-->  
190 - <!--<td></td>-->  
191 - <!--<td></td>-->  
192 - <!--<td></td>-->  
193 - <!--<td></td>-->  
194 - <!--<td></td>-->  
195 - <!--<td></td>-->  
196 - <!--<td></td>-->  
197 - <!--</tr>-->  
198 - <!--<tr>-->  
199 - <!--<td></td>-->  
200 - <!--<td></td>-->  
201 - <!--<td></td>-->  
202 - <!--<td></td>-->  
203 - <!--<td></td>-->  
204 - <!--<td></td>-->  
205 - <!--<td></td>-->  
206 - <!--<td></td>-->  
207 - <!--</tr>-->  
208 - <!--<tr>-->  
209 - <!--<td></td>-->  
210 - <!--<td></td>-->  
211 - <!--<td></td>-->  
212 - <!--<td></td>-->  
213 - <!--<td></td>-->  
214 - <!--<td></td>-->  
215 - <!--<td></td>-->  
216 - <!--<td></td>-->  
217 - <!--</tr>-->  
218 - <!--<tr>-->  
219 - <!--<td></td>-->  
220 - <!--<td></td>-->  
221 - <!--<td></td>-->  
222 - <!--<td></td>-->  
223 - <!--<td></td>-->  
224 - <!--<td></td>-->  
225 - <!--<td></td>-->  
226 - <!--<td></td>-->  
227 - <!--</tr>-->  
228 - <!--<tr>-->  
229 - <!--<td></td>-->  
230 - <!--<td></td>-->  
231 - <!--<td></td>-->  
232 - <!--<td></td>-->  
233 - <!--<td></td>-->  
234 - <!--<td></td>-->  
235 - <!--<td></td>-->  
236 - <!--<td></td>-->  
237 - <!--</tr>-->  
238 - <!--<tr>-->  
239 - <!--<td></td>-->  
240 - <!--<td></td>-->  
241 - <!--<td></td>-->  
242 - <!--<td></td>-->  
243 - <!--<td></td>-->  
244 - <!--<td></td>-->  
245 - <!--<td></td>-->  
246 - <!--<td></td>-->  
247 - <!--</tr>-->  
248 - <!--<tr>-->  
249 - <!--<td></td>-->  
250 - <!--<td></td>-->  
251 - <!--<td></td>-->  
252 - <!--<td></td>-->  
253 - <!--<td></td>-->  
254 - <!--<td></td>-->  
255 - <!--<td></td>-->  
256 - <!--<td></td>-->  
257 - <!--</tr>-->  
258 - <!--<tr>-->  
259 - <!--<td></td>-->  
260 - <!--<td></td>-->  
261 - <!--<td></td>-->  
262 - <!--<td></td>-->  
263 - <!--<td></td>-->  
264 - <!--<td></td>-->  
265 - <!--<td></td>-->  
266 - <!--<td></td>-->  
267 - <!--</tr>-->  
268 - <!--<tr>-->  
269 - <!--<td></td>-->  
270 - <!--<td></td>-->  
271 - <!--<td></td>-->  
272 - <!--<td></td>-->  
273 - <!--<td></td>-->  
274 - <!--<td></td>-->  
275 - <!--<td></td>-->  
276 - <!--<td></td>-->  
277 - <!--</tr>-->  
278 - <!--<tr>-->  
279 - <!--<td></td>-->  
280 - <!--<td></td>-->  
281 - <!--<td></td>-->  
282 - <!--<td></td>-->  
283 - <!--<td></td>-->  
284 - <!--<td></td>-->  
285 - <!--<td></td>-->  
286 - <!--<td></td>-->  
287 - <!--</tr>-->  
288 - <!--</table>-->  
289 </div> 40 </div>
290 </div> 41 </div>
frontend/views/cabinet/users.php
1 <?php 1 <?php
  2 + use frontend\models\IntellectualProperty;
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;
5 use yii\widgets\ActiveForm; 6 use yii\widgets\ActiveForm;
  7 + use yii\widgets\Pjax;
6 8
7 /** 9 /**
8 - * @var View $this 10 + * @var View $this
  11 + * @var Report[] $reports
9 */ 12 */
10 ?> 13 ?>
11 <div class="style cab_content_list"> 14 <div class="style cab_content_list">
@@ -23,51 +26,45 @@ @@ -23,51 +26,45 @@
23 ] 26 ]
24 ) ?> 27 ) ?>
25 </div> 28 </div>
26 - <div class="style table-forms-wrapp">  
27 - <table class="table-1" cellpadding="0" cellspacing="0" border="0">  
28 - <tr>  
29 - <td>№<br/>п/п</td>  
30 - <td>Користувач</td>  
31 - <td>Виконавець</td>  
32 - <td>Твір</td>  
33 - <td>Кількість сповіщень</td>  
34 - <td>Перерахована сума</td>  
35 - </tr>  
36 -  
37 - <tr>  
38 - <td>1</td>  
39 - <td>Радіо "BOOM"</td>  
40 - <td>Джорж Вашингтон</td>  
41 - <td>Нью-Йорк</td>  
42 - <td>10</td>  
43 - <td>100</td>  
44 - </tr>  
45 - <tr>  
46 - <td>2</td>  
47 - <td>Радіо "MUSOFF"</td>  
48 - <td>Джорж Вашингтон</td>  
49 - <td>Калифорнія</td>  
50 - <td>8</td>  
51 - <td>80</td>  
52 - </tr>  
53 - <tr>  
54 - <td>3</td>  
55 - <td>Радіо "MUSOFF"</td>  
56 - <td>Джорж Вашингтон</td>  
57 - <td>Іллінойс</td>  
58 - <td>6</td>  
59 - <td>60</td>  
60 - </tr>  
61 - <tr>  
62 - <td></td>  
63 - <td></td>  
64 - <td></td>  
65 - <td></td>  
66 - <td></td>  
67 - <td></td>  
68 - </tr>  
69 - </table>  
70 - </div> 29 + <?php
  30 + Pjax::begin(
  31 + [
  32 + 'id' => 'users-table',
  33 + 'options' => [
  34 + 'class' => 'style table-forms-wrapp',
  35 + ],
  36 + ]
  37 + );
  38 + ?>
  39 + <table class="table-1" cellpadding="0" cellspacing="0" border="0">
  40 + <tr>
  41 + <td>№<br/>п/п</td>
  42 + <td>Користувач</td>
  43 + <td>Виконавець</td>
  44 + <td>Твір</td>
  45 + <td>Кількість сповіщень</td>
  46 + <td>Перерахована сума</td>
  47 + </tr>
  48 + <?php
  49 + foreach ($reports as $index => $report) {
  50 + ?>
  51 + <tr>
  52 + <?php
  53 + echo Html::tag('td', ++$index);
  54 + echo Html::tag('td', $report->user);
  55 + echo Html::tag('td', $report->artist);
  56 + echo Html::tag('td', $report->intellectualProperty->title);
  57 + echo Html::tag('td', $report->count);
  58 + echo Html::tag('td', $report->sum);
  59 + ?>
  60 + </tr>
  61 + <?php
  62 + }
  63 + ?>
  64 + </table>
  65 + <?php
  66 + Pjax::end();
  67 + ?>
71 </div> 68 </div>
72 </div> 69 </div>
73 </div> 70 </div>
@@ -83,7 +80,7 @@ @@ -83,7 +80,7 @@
83 <?php 80 <?php
84 $form = ActiveForm::begin( 81 $form = ActiveForm::begin(
85 [ 82 [
86 - 'action' => ['/cabinet/users-add'], 83 + 'action' => [ '/cabinet/users-add' ],
87 'id' => 'users-add-form', 84 'id' => 'users-add-form',
88 ] 85 ]
89 ); 86 );
@@ -91,17 +88,29 @@ @@ -91,17 +88,29 @@
91 ?> 88 ?>
92 <div class="modal-body forms-cabinet forms-2"> 89 <div class="modal-body forms-cabinet forms-2">
93 <?php 90 <?php
94 - echo $form->field($addIntProp, 'title');  
95 - echo $form->field($addIntProp, 'registration_date')->textInput([  
96 - 'class' => '_datepicker form-control',  
97 - ]);  
98 - echo $form->field($addIntProp, 'genre');  
99 - echo $form->field($addIntProp, 'author_role');  
100 - echo $form->field($addIntProp, 'percent');  
101 - echo $form->field($addIntProp, 'calculated');  
102 - echo $form->field($addIntProp, 'play_count'); 91 + echo $form->field($report, 'user')
  92 + ->textInput();
  93 + echo $form->field($report, 'artist');
  94 + echo $form->field($report, 'intellectual_property_id')
  95 + ->dropDownList(
  96 + IntellectualProperty::find()
  97 + ->asArray()
  98 + ->select(
  99 + [
  100 + 'title',
  101 + 'id',
  102 + ]
  103 + )
  104 + ->indexBy('id')
  105 + ->column()
  106 + );
  107 + echo $form->field($report, 'count')
  108 + ->textInput();
  109 + echo $form->field($report, 'sum')
  110 + ->textInput();
103 ?> 111 ?>
104 </div> 112 </div>
  113 + <div class="clearfix"></div>
105 <div class="modal-footer btn-submit-blue"> 114 <div class="modal-footer btn-submit-blue">
106 <?php 115 <?php
107 echo Html::submitButton( 116 echo Html::submitButton(
frontend/web/js/script.js
@@ -147,6 +147,11 @@ $(document).ready(function(){ @@ -147,6 +147,11 @@ $(document).ready(function(){
147 return false; 147 return false;
148 }); 148 });
149 149
  150 + $(document).on('beforeSubmit', '#users-add-form', function(e) {
  151 + postForm(this, true, 'users-table', true, true);
  152 + return false;
  153 + });
  154 +
150 $(document).on('beforeSubmit', '#passport-form', function(e) { 155 $(document).on('beforeSubmit', '#passport-form', function(e) {
151 postForm(this); 156 postForm(this);
152 return false; 157 return false;
@@ -231,19 +236,35 @@ $(document).ready(function(){ @@ -231,19 +236,35 @@ $(document).ready(function(){
231 ); 236 );
232 } 237 }
233 238
234 - function postForm(context) { 239 + function postForm(context, reload_pjax, pjax, close, reset) {
235 $.post($(context).attr('action'), $(context).serialize(), function(data) { 240 $.post($(context).attr('action'), $(context).serialize(), function(data) {
236 var type; 241 var type;
237 if(data.error) { 242 if(data.error) {
238 type = 'danger'; 243 type = 'danger';
239 } else { 244 } else {
240 type = 'success'; 245 type = 'success';
  246 + if(close) {
  247 + tryClose(context);
  248 + }
  249 + if(reset) {
  250 + context.reset();
  251 + }
241 } 252 }
242 showStatus(data.message, type); 253 showStatus(data.message, type);
243 - reload($(context).parents('.pjax_container').attr('id')); 254 + if(reload_pjax) {
  255 + if(pjax) {
  256 + reload(pjax);
  257 + } else {
  258 + reload($(context).parents('.pjax_container').attr('id'));
  259 + }
  260 + }
244 }.bind(this)); 261 }.bind(this));
245 } 262 }
246 263
  264 + function tryClose(context) {
  265 + $(context).parents('.modal').modal('hide');
  266 + }
  267 +
247 function showStatus(txt, type) { 268 function showStatus(txt, type) {
248 $.notify({ 269 $.notify({
249 message: txt 270 message: txt