add backend theme AdminLte, bind reception/transaction to a permission

This commit is contained in:
2015-11-23 19:55:49 +01:00
parent e13866d7da
commit bcae71155e
25 changed files with 993 additions and 128 deletions

View File

@@ -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;
}

View File

@@ -0,0 +1,78 @@
<?php
namespace backend\components;
use \Yii;
class LTEAdminMenu extends \dmstr\widgets\Menu{
/**
* Checks whether a menu item is active.
* This is done by checking if [[route]] and [[params]] match that specified in the `url` option of the menu item.
* When the `url` option of a menu item is specified in terms of an array, its first element is treated
* as the route for the item and the rest of the elements are the associated parameters.
* Only when its route and parameters match [[route]] and [[params]], respectively, will a menu item
* be considered active.
* @param array $item the menu item to be checked
* @return boolean whether the menu item is active
*/
protected function isItemActive($item)
{
if (isset($item['target_url']) && is_array($item['target_url']) ) {
foreach ($item['target_url'] as $target){
$route = $target;
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]) {
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;
}
}
?>