From dcb4e862b38ff0f5ebf99a6175689455c76a2a71 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Sun, 3 Jan 2016 19:16:44 +0100 Subject: [PATCH] change version to v.0.0.14 , add admin menu changes, add collection change --- backend/components/AdminMenuStructure.php | 7 +++++- backend/models/AccountStateSearch.php | 17 +++++++++----- backend/models/CollectionSearch.php | 10 +++++++++ changelog.txt | 4 ++++ common/config/params.php | 2 +- common/models/Collection.php | 27 ++++++++++++++++++++++- 6 files changed, 59 insertions(+), 8 deletions(-) diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index c39631c..918a8c2 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -4,6 +4,7 @@ namespace backend\components; use Yii; use common\models\Order; use yii\helpers\Html; +use common\components\RoleDefinition; class AdminMenuStructure{ @@ -43,18 +44,22 @@ class AdminMenuStructure{ ///////////////////////////// // Beállítások ///////////////////////////// + if ( RoleDefinition::isAdmin()){ $items[] = ['label' => 'Felhasználók', 'url' =>['/user/index']]; $items[] = ['label' => 'Jogosultságok', 'url' =>['/user/role']]; $this->menuItems[] = ['label' => 'Beállítások', 'url' => $this->emptyUrl, 'items' => $items ]; + } ///////////////////////////// // Törszadatok ///////////////////////////// $items = []; $items[] = ['label' => 'Raktárak', 'url' =>['/warehouse/index']]; - $items[] = ['label' => 'Kasszák', 'url' =>['/account/index']]; + if ( RoleDefinition::isAdmin()){ + $items[] = ['label' => 'Kasszák', 'url' =>['/account/index']]; + } $items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ]; $items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ]; $items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ]; diff --git a/backend/models/AccountStateSearch.php b/backend/models/AccountStateSearch.php index c11b175..359921a 100644 --- a/backend/models/AccountStateSearch.php +++ b/backend/models/AccountStateSearch.php @@ -7,6 +7,7 @@ use yii\base\Model; use yii\data\ActiveDataProvider; use common\models\AccountState; use common\components\RoleDefinition; +use common\models\Account; /** * AccountStateSearch represents the model behind the search form about `common\models\AccountState`. @@ -54,10 +55,16 @@ class AccountStateSearch extends AccountState { $query = AccountState::find(); + $query->innerJoinWith('account'); if ( !RoleDefinition::isAdmin() ){ $query->innerJoin("user_account_assignment",'account_state.id_account = user_account_assignment.id_account' ); $query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]); + $query->andWhere(['account.type' => Account::TYPE_ALL ]); + + if ( RoleDefinition::isReception()){ + $query->andWhere(['transfer.id_user' => Yii::$app->user->id ]); + } } $dataProvider = new ActiveDataProvider([ @@ -76,13 +83,13 @@ class AccountStateSearch extends AccountState $query->orderBy(['created_at' => SORT_DESC]); $query->andFilterWhere([ - 'id_user' => $this->id_user, - 'id_account' => $this->id_account, - 'type' => $this->type, + 'account_state.id_user' => $this->id_user, + 'account_state.id_account' => $this->id_account, + 'account_state.type' => $this->type, ]); - $query->andFilterWhere([ '>=', 'created_at', $this->timestampStart ] ); - $query->andFilterWhere([ '<', 'created_at', $this->timestampEnd ] ); + $query->andFilterWhere([ '>=', 'account_state.created_at', $this->timestampStart ] ); + $query->andFilterWhere([ '<', 'account_state.created_at', $this->timestampEnd ] ); return $dataProvider; } diff --git a/backend/models/CollectionSearch.php b/backend/models/CollectionSearch.php index a07a715..d6265a7 100644 --- a/backend/models/CollectionSearch.php +++ b/backend/models/CollectionSearch.php @@ -8,6 +8,7 @@ use yii\data\ActiveDataProvider; use common\models\Collection; use common\components\Helper; use common\components\RoleDefinition; +use common\models\Account; /** * CollectionSearch represents the model behind the search form about `common\models\Collection`. @@ -56,11 +57,20 @@ class CollectionSearch extends Collection public function search($params) { $query = Collection::find(); + + $query->innerJoinWith('account'); if ( !RoleDefinition::isAdmin() ){ $query->innerJoin("user_account_assignment",'collection.id_account = user_account_assignment.id_account' ); $query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]); + + $query->andWhere(['account.type' => Account::TYPE_ALL ]); + + if ( RoleDefinition::isReception()){ + $query->andWhere(['transfer.id_user' => Yii::$app->user->id ]); + } + } $dataProvider = new ActiveDataProvider([ diff --git a/changelog.txt b/changelog.txt index d5ce27c..e73125e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +-0.0.14 + - add hidden account + - add cart payout/delete per row + - -0.0.13 - add new profile rocho-net -0.0.12 diff --git a/common/config/params.php b/common/config/params.php index fca7df1..1b2a86c 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -3,5 +3,5 @@ return [ 'adminEmail' => 'rocho02@gmail.com', 'supportEmail' => 'rocho02@gmail.com', 'user.passwordResetTokenExpire' => 3600, - 'version' => 'v0.0.13' + 'version' => 'v0.0.14' ]; diff --git a/common/models/Collection.php b/common/models/Collection.php index 4914f53..a7c083d 100644 --- a/common/models/Collection.php +++ b/common/models/Collection.php @@ -68,6 +68,22 @@ class Collection extends \common\models\BaseFitnessActiveRecord [['start', 'end', 'created_at', 'updated_at'], 'safe'] ]; } + + + public function getAccount(){ + return $this->hasOne( Account::className(), ["id_account" =>"id_account" ] ) ; + } + + public function getAccountName(){ + $result = ""; + $account = $this->account; + if (isset($account)){ + $result = $account->name; + } + + return $result; + } + /** * @inheritdoc @@ -116,9 +132,18 @@ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$ty $query = new Query(); + $query->innerJoin("account",'account.id_account = collection.id_account' ); + if ( !RoleDefinition::isAdmin() ){ $query->innerJoin("user_account_assignment",'collection.id_account = user_account_assignment.id_account' ); $query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]); + + $query->andWhere(['account.type' => Account::TYPE_ALL ]); + + if ( RoleDefinition::isReception()){ + $query->andWhere(['transfer.id_user' => Yii::$app->user->id ]); + } + } $query->addSelect( [ @@ -129,7 +154,7 @@ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$ty $query->from('collection'); $query->andFilterWhere([ - 'id_account' => $idAccount, + 'collection.id_account' => $idAccount, ]); $query->andFilterWhere(['collection.id_user' => $idUser]);