door manager
This commit is contained in:
@@ -8,7 +8,6 @@ use backend\models\CitySearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use yii\db\Query;
|
||||
use yii\helpers\Json;
|
||||
|
||||
@@ -36,5 +35,5 @@ class BackendController extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use backend\models\CitySearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use yii\db\Query;
|
||||
use yii\helpers\Json;
|
||||
|
||||
@@ -34,7 +33,7 @@ class CityController extends \backend\controllers\BackendController
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists all City models.
|
||||
@@ -128,14 +127,14 @@ class CityController extends \backend\controllers\BackendController
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Your controller action to fetch the list
|
||||
*/
|
||||
public function actionNameList($search = null) {
|
||||
$query = new Query();
|
||||
|
||||
|
||||
$query->select ( [
|
||||
'name',
|
||||
'min(zip) as zip',
|
||||
@@ -158,7 +157,7 @@ class CityController extends \backend\controllers\BackendController
|
||||
*/
|
||||
public function actionZipList($search = null) {
|
||||
$query = new Query();
|
||||
|
||||
|
||||
$query->select ( [
|
||||
'name',
|
||||
'min(zip) as zip',
|
||||
|
||||
@@ -12,7 +12,6 @@ use yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use backend\models\CustomerUpdate;
|
||||
use backend\models\CustomerNewsLetterModel;
|
||||
use yii\db\Query;
|
||||
@@ -24,7 +23,7 @@ use yii\data\ActiveDataProvider;
|
||||
class CustomerController extends \backend\controllers\BackendController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
@@ -130,10 +129,10 @@ class CustomerController extends \backend\controllers\BackendController
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new CustomerCreate();
|
||||
|
||||
|
||||
$model->country = "Magyarország";
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_customer]);
|
||||
@@ -157,9 +156,9 @@ class CustomerController extends \backend\controllers\BackendController
|
||||
if (($model = CustomerUpdate::findOne($id)) == null) {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
|
||||
$model->birthdate= isset($model->birthdate ) ? Yii::$app->formatter->asDate($model->birthdate) :'';
|
||||
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_customer]);
|
||||
@@ -198,24 +197,24 @@ class CustomerController extends \backend\controllers\BackendController
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function actionMail(){
|
||||
$model = new CustomerNewsLetterModel();
|
||||
|
||||
|
||||
$query = new Query();
|
||||
$query->distinct();
|
||||
$query->select([ 'email']);
|
||||
$query->from("customer");
|
||||
$query->andWhere(['newsletter' => 1]);
|
||||
$query->andWhere(['status' => Customer::STATUS_ACTIVE]);
|
||||
|
||||
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||
|
||||
|
||||
|
||||
|
||||
$message = \Yii::$app->mailer->compose ( );
|
||||
|
||||
|
||||
$message
|
||||
->setFrom ( "noreply@fitnessadmin.hu" )
|
||||
->setBcc(['rocho02@gmail.com',"rocho02@freemail.hu"])
|
||||
@@ -225,9 +224,9 @@ class CustomerController extends \backend\controllers\BackendController
|
||||
->send ();
|
||||
return $this->redirect(['customer/mail']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->render('mail', [ 'model' => $model ]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ use backend\models\UserCreate;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use backend\models\UserUpdate;
|
||||
use common\models\Account;
|
||||
use common\models\UserAccountAssignment;
|
||||
@@ -20,7 +19,7 @@ use common\components\RoleDefinition;
|
||||
*/
|
||||
class UserController extends \backend\controllers\BackendController
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
@@ -45,8 +44,8 @@ class UserController extends \backend\controllers\BackendController
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists all User models.
|
||||
* @return mixed
|
||||
@@ -55,8 +54,8 @@ class UserController extends \backend\controllers\BackendController
|
||||
{
|
||||
$searchModel = new UserSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
@@ -84,25 +83,25 @@ class UserController extends \backend\controllers\BackendController
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new UserCreate();
|
||||
|
||||
|
||||
$accounts = Account::readAccounts();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
|
||||
|
||||
$this->updateAccountAssignments($model);
|
||||
|
||||
|
||||
return $this->redirect(['index' ]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function updateAccountAssignments($model){
|
||||
|
||||
|
||||
echo "saving accounts";
|
||||
UserAccountAssignment::deleteAll(['id_user' => $model->id]);
|
||||
foreach ( $model->selected_accounts as $id_account ){
|
||||
@@ -112,7 +111,7 @@ class UserController extends \backend\controllers\BackendController
|
||||
$uaa->id_account = $id_account;
|
||||
$uaa->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +123,7 @@ class UserController extends \backend\controllers\BackendController
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = UserUpdate::findOne(['id' => $id]);
|
||||
|
||||
|
||||
if ( Yii::$app->authManager->checkAccess($model->id, 'admin')){
|
||||
$model->role = 'admin';
|
||||
} else if ( Yii::$app->authManager->checkAccess($model->id, 'employee')){
|
||||
@@ -132,16 +131,16 @@ class UserController extends \backend\controllers\BackendController
|
||||
}else if ( Yii::$app->authManager->checkAccess($model->id, 'reception')){
|
||||
$model->role = 'reception';
|
||||
}
|
||||
|
||||
|
||||
if ( $model == null ){
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
|
||||
$accounts = Account::readAccounts();
|
||||
|
||||
|
||||
$this->applyAccounts($model);
|
||||
|
||||
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
$this->updateAccountAssignments($model);
|
||||
@@ -153,7 +152,7 @@ class UserController extends \backend\controllers\BackendController
|
||||
'accounts' => $accounts,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function applyAccounts($model ){
|
||||
$assignedAccounts = $model->userAccountAssignments;
|
||||
foreach ($assignedAccounts as $acc ){
|
||||
@@ -171,12 +170,12 @@ class UserController extends \backend\controllers\BackendController
|
||||
{
|
||||
|
||||
$user = $this->findModel($id);
|
||||
|
||||
|
||||
$user->updateAttributes(['status' => User::STATUS_DELETED]);
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new User model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
@@ -185,17 +184,17 @@ class UserController extends \backend\controllers\BackendController
|
||||
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');
|
||||
@@ -209,7 +208,7 @@ class UserController extends \backend\controllers\BackendController
|
||||
$model->permissions[] = $child->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->render('role', [
|
||||
'model' => $model,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user