diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index 68ff846..5976176 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -8,6 +8,7 @@ use yii\helpers\Html; class AdminMenuStructure{ public $menuItems; + public $emptyUrl = '#';//maybe null public function __construct(){ $this->menuItems = []; @@ -43,7 +44,8 @@ class AdminMenuStructure{ // Beállítások ///////////////////////////// $items[] = ['label' => 'Felhasználók', 'url' =>['/user/index']]; - $this->menuItems[] = ['label' => 'Beállítások', 'url' => null, + $items[] = ['label' => 'Jogosultságok', 'url' =>['/user/role']]; + $this->menuItems[] = ['label' => 'Beállítások', 'url' => $this->emptyUrl, 'items' => $items ]; @@ -57,7 +59,7 @@ class AdminMenuStructure{ $items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ]; $items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ]; // $items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ]; - $this->menuItems[] = ['label' => 'Törszadatok', 'url' => null, + $this->menuItems[] = ['label' => 'Törszadatok', 'url' =>$this->emptyUrl, 'items' => $items ]; @@ -65,10 +67,10 @@ class AdminMenuStructure{ // BÉRLETEK ///////////////////////////// $items = []; - $items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ]; + $items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] , 'target_url' => ['/customer/index' ,'/customer/view','/ticket/index-customer'] ]; $items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ]; $items[] = ['label' => 'Bérletek', 'url' => ['/ticket/index' , 'TicketSearch[start]' =>$today,'TicketSearch[end]' => $tomorrow ] ]; - $this->menuItems[] = ['label' => 'Bérletek/Vendégek', 'url' => null, + $this->menuItems[] = ['label' => 'Bérletek/Vendégek', 'url' => $this->emptyUrl, 'items' => $items ]; @@ -78,7 +80,7 @@ class AdminMenuStructure{ $items = []; $items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ]; $items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ]; - $this->menuItems[] = ['label' => 'Termékek', 'url' => null, + $this->menuItems[] = ['label' => 'Termékek', 'url' => $this->emptyUrl, 'items' => $items ]; ///////////////////////////// @@ -88,7 +90,7 @@ class AdminMenuStructure{ $items[] = ['label' => 'Tranzakciók', 'url' => ['/transfer/index' , 'TransferSearch[start]' =>$today,'TransferSearch[end]' => $tomorrow ] ]; $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ]; $items[] = ['label' => 'Zárások', 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$todayDatetime,'CollectionSearch[end]' => $tomorrowDatetime ] ]; - $this->menuItems[] = ['label' => 'Pénzügy', 'url' => null, + $this->menuItems[] = ['label' => 'Pénzügy', 'url' => $this->emptyUrl, 'items' => $items ]; @@ -112,7 +114,7 @@ class AdminMenuStructure{ public function run(){ $this->addUserMainMenu(); - $this->addLoginMainMenu(); +// $this->addLoginMainMenu(); return $this->menuItems; } diff --git a/backend/components/LTEAdminMenu.php b/backend/components/LTEAdminMenu.php new file mode 100644 index 0000000..700cd08 --- /dev/null +++ b/backend/components/LTEAdminMenu.php @@ -0,0 +1,78 @@ +controller) { + $route = Yii::$app->controller->module->getUniqueId() . '/' . $route; + } + $arrayRoute = explode('/', ltrim($route, '/')); + $arrayThisRoute = explode('/', $this->route); + if ($arrayRoute[0] !== $arrayThisRoute[0]) { + continue; + } + if (isset($arrayRoute[1]) && $arrayRoute[1] !== $arrayThisRoute[1]) { + continue; + } + if (isset($arrayRoute[2]) && $arrayRoute[2] !== $arrayThisRoute[2]) { + continue; + } + return true; + } + return false; + }else if (isset($item['url']) && is_array($item['url']) && isset($item['url'][0])) { + $route = $item['url'][0]; + if ($route[0] !== '/' && Yii::$app->controller) { + $route = Yii::$app->controller->module->getUniqueId() . '/' . $route; + } + $arrayRoute = explode('/', ltrim($route, '/')); + $arrayThisRoute = explode('/', $this->route); + if ($arrayRoute[0] !== $arrayThisRoute[0]) { + return false; + } + if (isset($arrayRoute[1]) && $arrayRoute[1] !== $arrayThisRoute[1]) { + return false; + } + if (isset($arrayRoute[2]) && $arrayRoute[2] !== $arrayThisRoute[2]) { + return false; + } +// unset($item['url']['#']); +// if (count($item['url']) > 1) { +// foreach (array_splice($item['url'], 1) as $name => $value) { +// if ($value !== null && (!isset($this->params[$name]) || $this->params[$name] != $value)) { +// return false; +// } +// } +// } + return true; + } + return false; + } + + } + + +?> \ No newline at end of file diff --git a/backend/controllers/SiteController.php b/backend/controllers/SiteController.php index 52a7eac..73bd4ec 100644 --- a/backend/controllers/SiteController.php +++ b/backend/controllers/SiteController.php @@ -66,6 +66,10 @@ class SiteController extends Controller } $model = new LoginForm(); + $model->roles = [ + 'admin', + 'employee' + ]; if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { diff --git a/backend/controllers/UserController.php b/backend/controllers/UserController.php index 6a41097..60c42f4 100644 --- a/backend/controllers/UserController.php +++ b/backend/controllers/UserController.php @@ -30,9 +30,9 @@ class UserController extends \backend\controllers\BackendController 'rules' => [ // allow authenticated users [ - 'actions' => [ 'index','view' ], + 'actions' => [ 'index','view' ,'role'], 'allow' => true, - 'roles' => ['employee','admin','reception'], + 'roles' => ['employee','admin' ], ], // allow authenticated users [ @@ -176,6 +176,44 @@ class UserController extends \backend\controllers\BackendController return $this->redirect(['index']); } + + /** + * Creates a new User model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionRole() + { + $model = new \backend\models\RoleForm(); + + $model->availablePermissions = [ + [ + 'name' => "reception.transfers", + 'description' => 'Tranzakciók' + ] + ]; + + + + + if ($model->load(Yii::$app->request->post()) ) { + if ( $model->validate() && $model->save()){ + Yii::$app->session->setFlash('success', 'Jogosultságok elmentve'); + return $this->redirect(['role' ]); + } + }else{ + $am = Yii::$app->authManager; + $children = $am->getChildren(User::ROLE_RECEPTION); + $model->permissions = []; + foreach ($children as $child){ + $model->permissions[] = $child->name; + } + } + + return $this->render('role', [ + 'model' => $model, + ]); + } /** * Finds the User model based on its primary key value. diff --git a/backend/models/RoleForm.php b/backend/models/RoleForm.php new file mode 100644 index 0000000..40f555b --- /dev/null +++ b/backend/models/RoleForm.php @@ -0,0 +1,46 @@ +$attribute)) { + echo "invalid arr"; + $this->addError($attribute, 'Invalid array'); + } + } + ], + ]; + } + + public function save(){ + $am = \Yii::$app->authManager; + //remove all reception permission + $receptionItem = $am->getRole(User::ROLE_RECEPTION); + $am->removeChildren($receptionItem); + + if ( isset($receptionItem)){ + foreach ($this->permissions as $permissionName){ + $permission = $am->getPermission($permissionName); + if ( isset( $permission )){ + $am->addChild($receptionItem, $permission); + } + } + } + return true; + } + +} \ No newline at end of file diff --git a/backend/views/layouts-orig/main.php b/backend/views/layouts-orig/main.php new file mode 100644 index 0000000..88466f6 --- /dev/null +++ b/backend/views/layouts-orig/main.php @@ -0,0 +1,79 @@ +run(); +?> +beginPage() ?> + + +
+ + + = Html::csrfMetaTags() ?> ++ = nl2br(Html::encode($message)) ?> +
+ ++ The above error occurred while the Web server was processing your request. + Please contact us if you think this is a server error. Thank you. + Meanwhile, you may return to dashboard or try using the search + form. +
+ + +- The above error occurred while the Web server was processing your request. -
-- Please contact us if you think this is a server error. Thank you. -
- -Üdvözöljük adminisztrációs felületünkön
-- -
Kérem jelentkezzen be
+ + 'login-form', 'enableClientValidation' => false]); ?> + + = $form + ->field($model, 'username', $fieldOptions1) + ->label(false) + ->textInput(['placeholder' => $model->getAttributeLabel('username')]) ?> + + = $form + ->field($model, 'password', $fieldOptions2) + ->label(false) + ->passwordInput(['placeholder' => $model->getAttributeLabel('password')]) ?> + ++ The above error occurred while the Web server was processing your request. +
++ Please contact us if you think this is a server error. Thank you. +
+ +Üdvözöljük adminisztrációs felületünkön
+ ++ +