From 3ebbbaa9a6142eab82c48a1191f5c40e4ddadefd Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 30 Dec 2016 14:29:22 +0200 Subject: [PATCH] -Reports --- frontend/controllers/CabinetController.php | 76 +++++++++++++++++++++++++++++++++++++++++++++------------------------------- frontend/views/cabinet/users.php | 10 +++++++--- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php index 8fcbe26..ae6d2d1 100755 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php @@ -26,7 +26,7 @@ public function behaviors() { return [ - 'verbs' => [ + 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'personal' => [ 'post' ], @@ -38,7 +38,7 @@ 'rules' => [ [ 'allow' => true, - 'roles' => ['@'], + 'roles' => [ '@' ], ], ], ], @@ -63,12 +63,11 @@ $userPassport = new UserPassport(); } - $table = IntellectualProperty::find() -// ->where( -// [ -// 'user_id' => \Yii::$app->user->identity->id, -// ] -// ) + $table = IntellectualProperty::find()// ->where( + // [ + // 'user_id' => \Yii::$app->user->identity->id, + // ] + // ) ->all(); return $this->render( @@ -81,7 +80,7 @@ ); } - public function actionSales($id = null) + public function actionSales($id = NULL) { $newRecord = false; if ($id) { @@ -127,12 +126,11 @@ public function actionList() { - $table = IntellectualProperty::find() -// ->where( -// [ -// 'user_id' => \Yii::$app->user->identity->id, -// ] -// ) + $table = IntellectualProperty::find()// ->where( + // [ + // 'user_id' => \Yii::$app->user->identity->id, + // ] + // ) ->all(); return $this->render( 'list', @@ -157,17 +155,33 @@ public function actionNotifications() { - $table = Report::find()->all(); - return $this->render('notifications', [ - 'table' => $table, - ]); + $table = Report::find() + ->all(); + return $this->render( + 'notifications', + [ + 'table' => $table, + ] + ); } public function actionUsers() { - $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( 'users', [ @@ -279,7 +293,7 @@ $response = \Yii::$app->response; $response->format = $response::FORMAT_JSON; - if (!empty( $request->post('id') )) { + if (!empty($request->post('id'))) { $role = IntellectualProperty::findOne($request->post('id')); if ($role->delete()) { return [ @@ -320,15 +334,15 @@ ]; } } - + public function actionUpdateRole() { $request = \Yii::$app->request; $response = \Yii::$app->response; $response->format = $response::FORMAT_JSON; - + $role = CreativeRole::findOne($request->get('id')); - + if ($role->load($request->post()) && $role->save()) { return [ 'success' => true, @@ -341,17 +355,17 @@ ]; } } - + public function actionGetRoleForm() { $request = \Yii::$app->request; $response = \Yii::$app->response; $response->format = $response::FORMAT_JSON; - + $model = CreativeRole::findOne($request->post('id')); return [ - 'answer' => $this->renderPartial('_update_form', ['model' => $model]) + 'answer' => $this->renderPartial('_update_form', [ 'model' => $model ]), ]; } @@ -361,7 +375,7 @@ $response = \Yii::$app->response; $response->format = $response::FORMAT_JSON; - if (!empty( $request->post('id') )) { + if (!empty($request->post('id'))) { $role = CreativeRole::findOne($request->post('id')); if ($role->delete()) { return [ @@ -385,7 +399,7 @@ public function findProperty($id) { $model = IntellectualProperty::findOne($id); - if (empty( $model )) { + if (empty($model)) { throw new NotFoundHttpException(); } return $model; diff --git a/frontend/views/cabinet/users.php b/frontend/views/cabinet/users.php index 2ca5cca..4a7b3a5 100755 --- a/frontend/views/cabinet/users.php +++ b/frontend/views/cabinet/users.php @@ -1,4 +1,5 @@ user->identity; ?>
Звіт про загальну суму винагороди (у розрізі користувачів)
- isAdmin()) echo Html::button( 'Добавить', [ 'type' => 'button', @@ -56,7 +60,7 @@ user); - echo Html::tag('td', $report->artist); + echo Html::tag('td', ''); echo Html::tag('td', $report->intellectualProperty->title); echo Html::tag('td', $report->count); echo Html::tag('td', $report->sum); @@ -98,7 +102,7 @@ field($report, 'user') ->textInput(); - echo $form->field($report, 'artist'); +// echo $form->field($report, 'artist'); echo $form->field($report, 'intellectual_property_id') ->dropDownList( IntellectualProperty::find() -- libgit2 0.21.4