namespace app\controllers;
+use Yii;
+use yii_app\records\AdminGroup;
use yii_app\records\MarketplacePricesLog;
use yii_app\records\MarketplacePricesLogSearch;
use yii\web\Controller;
*/
public function actionIndex()
{
+ if (($resp = $this->checkAccess()) !== null) {
+ return $resp;
+ }
$searchModel = new MarketplacePricesLogSearch();
$dataProvider = $searchModel->search($this->request->queryParams);
*/
public function actionView($id)
{
+ if (($resp = $this->checkAccess()) !== null) {
+ return $resp;
+ }
return $this->render('view', [
'model' => $this->findModel($id),
]);
*/
public function actionCreate()
{
+ if (($resp = $this->checkAccess()) !== null) {
+ return $resp;
+ }
$model = new MarketplacePricesLog();
if ($this->request->isPost) {
*/
public function actionUpdate($id)
{
+ if (($resp = $this->checkAccess()) !== null) {
+ return $resp;
+ }
$model = $this->findModel($id);
if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
*/
public function actionDelete($id)
{
+ if (($resp = $this->checkAccess()) !== null) {
+ $this->redirect(['/site/index']);
+ }
+
$this->findModel($id)->delete();
return $this->redirect(['index']);
throw new NotFoundHttpException('The requested page does not exist.');
}
+
+ private function checkAccess() {
+ $groupId = Yii::$app->user->identity->group_id;
+
+ if (!in_array($groupId, [
+ AdminGroup::GROUP_IT,
+ ], true)) {
+ return $this->render('/site/index');
+ }
+
+ return null;
+ }
}
<?php
use yii\widgets\ActiveForm;
+use yii_app\records\Admin;
+use yii_app\records\AdminGroup;
use yii_app\records\MarketplacePrices;
use yii\helpers\Html;
use yii\helpers\Url;
<div class="d-flex justify-content-between">
<div>
<?= Html::a('Добавить цены', ['create'], ['class' => 'btn btn-success ']) ?>
+ <?php if(in_array(Admin::findOne([Yii::$app->user->id])->group_id, [AdminGroup::GROUP_IT, AdminGroup::GROUP_RS_DIRECTOR])) { ?>
<?= Html::a('История цен', ['/marketplace-prices-log/index'], ['class' => 'btn btn-success']) ?>
+ <?php } ?>
<?= Html::a('Товары маркетплейсов', ['/matrix-erp/index'], ['class' => 'btn btn-success']) ?>
</div>