diff --git a/.gitignore b/.gitignore index 346d3b2..e587688 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ composer.phar phpunit.phar # local phpunit config /phpunit.xml + +/node_modules diff --git a/Gruntfile.coffee b/Gruntfile.coffee new file mode 100644 index 0000000..c663c91 --- /dev/null +++ b/Gruntfile.coffee @@ -0,0 +1,62 @@ +module.exports = (grunt) -> + + # Project configuration. + grunt.initConfig + pkg: grunt.file.readJSON('package.json') + + config: + src: 'assets/coffee' + dest: 'assets/js' + + clean: + build: + src: [ 'frontend/web/stylesheet','backend/web/stylesheet' ] + + compass: + frontend: + options: + sassDir: 'frontend/web/scss' + cssDir: 'frontend/web/stylesheet' + backend: + options: + sassDir: 'backend/web/scss' + cssDir: 'backend/web/stylesheet' + + coffee: + frontend: + options: + sourceMap: true + bare: false + join: true + files: + 'frontend/web/js/frontend.js': ['frontend/web/coffee/**/*.coffee'] + backend: + options: + sourceMap: true + bare: false + join: true + files: + 'backend/web/js/backend.js': ['backend/web/coffee/**/*.coffee'] + + watch: + options: + spawn: false + interrupt: true + atBegin: true + interval: 500 + coffeewatch: + files: ['frontend/web/coffee/**/*.coffee','backend/web/coffee/**/*.coffee'] + tasks: ['any-newer:coffee'] + sasswatch: + files: ['frontend/web/scss/*.scss','backend/web/scss/*.scss'] + tasks: ['compass'] + + + #grunt.loadNpmTasks 'grunt-contrib-compass' + + require('matchdep').filterDev('grunt-*').forEach grunt.loadNpmTasks + + # Tasks + #grunt.registerTask 'default', ['concurrent:compile'] + grunt.registerTask 'default', ['compass','coffee'] + #grunt.registerTask 'production', ['clean', 'concurrent:compile', 'concurrent:optimize'] \ No newline at end of file diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php new file mode 100644 index 0000000..357f19b --- /dev/null +++ b/backend/components/AdminMenuStructure.php @@ -0,0 +1,97 @@ +menuItems = []; + } + + protected function can($authItem){ + $result = false; + if (\Yii::$app->user->can($authItem)) { + $result = true; + } + return $result; + } + + + + + + protected function addUserMainMenu(){ + + $userMainMenu = null; + $items = []; + if (!Yii::$app->user->isGuest) { + + + //$today = \Yii::$app->formatter->asDate( time() ); + $today = \Yii::$app->formatter->asDate( strtotime('today UTC') ); + $tomorrow = \Yii::$app->formatter->asDate( ( 60 *60 *24 + time())); + + $todayDatetime = \Yii::$app->formatter->asDatetime( strtotime('today UTC') ); + $tomorrowDatetime = \Yii::$app->formatter->asDatetime( strtotime('tomorrow UTC') ); + + + // if ( $this->can('backend.user.index')){ + $items[] = ['label' => 'Felhasználók', 'url' =>['/user/index']]; + // } + + $items[] = ['label' => 'Raktárak', 'url' =>['/warehouse/index']]; + $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'] ]; + $items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ]; + $items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ]; + $items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ]; + $items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ]; +// $items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ]; + + $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 ] ]; + + if ( count($items) > 0 ){ + $userMainMenu = ['label' => 'Beállítások', 'url' => null, + 'items' => $items + ]; + } + + if ( isset($userMainMenu)){ + $this->menuItems[] = $userMainMenu; + } + } + + } + + + protected function addLoginMainMenu(){ + if (Yii::$app->user->isGuest) { + $mainMenuItem= ['label' => 'Login', 'url' => ['/site/login']]; + } else { + $mainMenuItem= [ + 'label' => 'Kijelentkezés (' . Yii::$app->user->identity->username . ')', + 'url' => ['/site/logout'], + 'linkOptions' => ['data-method' => 'post'] + ]; + } + $this->menuItems[] = $mainMenuItem; + } + + + public function run(){ + $this->addUserMainMenu(); + $this->addLoginMainMenu(); + return $this->menuItems; + } + + +} \ No newline at end of file diff --git a/backend/config/main.php b/backend/config/main.php index a0b5fc9..fbb4bd2 100644 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -8,6 +8,7 @@ $params = array_merge( return [ 'id' => 'app-backend', + 'name' => 'Fitness Adminisztráció', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'backend\controllers', 'bootstrap' => ['log'], @@ -16,7 +17,15 @@ return [ 'user' => [ 'identityClass' => 'common\models\User', 'enableAutoLogin' => true, + 'identityCookie' => [ + 'name' => '_backendUser', // unique for backend + 'path'=>'/backend/web' // correct path for the backend app. + ] ], + 'session' => [ + 'name' => '_backendSessionId', // unique for backend + 'savePath' => __DIR__ . '/../runtime', // a temporary folder on backend + ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ diff --git a/backend/controllers/AccountController.php b/backend/controllers/AccountController.php new file mode 100644 index 0000000..cc91a32 --- /dev/null +++ b/backend/controllers/AccountController.php @@ -0,0 +1,124 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => [ 'index','view' ], + 'allow' => true, + 'roles' => ['employee','admin','reception'], + ], + // allow authenticated users + [ + 'actions' => [ 'create', 'update'], + 'allow' => true, + 'roles' => ['admin'], + ], + // everything else is denied + ], + ], + ]; + } + + + /** + * Lists all Account models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new AccountSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Account model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Account model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Account(); + $model->status = Account::STATUS_ACTIVE; + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_account]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Account model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_account]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + + /** + * Finds the Account model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Account the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Account::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/AccountStateController.php b/backend/controllers/AccountStateController.php new file mode 100644 index 0000000..2fcad74 --- /dev/null +++ b/backend/controllers/AccountStateController.php @@ -0,0 +1,119 @@ +search(Yii::$app->request->queryParams); + + $accounts = Account::read(); + $users = User::read(); + + + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'accounts' => $accounts, + 'users' => $users, + ]); + } + + /** + * Displays a single AccountState model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new AccountState model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new AccountState(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_account_state]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing AccountState model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_account_state]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing AccountState model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + */ + + /** + * Finds the AccountState model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return AccountState the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = AccountState::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/BackendController.php b/backend/controllers/BackendController.php new file mode 100644 index 0000000..3905997 --- /dev/null +++ b/backend/controllers/BackendController.php @@ -0,0 +1,40 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => ['create','index','view','update'], + 'allow' => true, + 'roles' => ['admin','employee','reception'], + ], + // everything else is denied + ], + ], + ]; + } + + +} diff --git a/backend/controllers/CardController.php b/backend/controllers/CardController.php new file mode 100644 index 0000000..c06d8a4 --- /dev/null +++ b/backend/controllers/CardController.php @@ -0,0 +1,171 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => ['create','index','view','update','list'], + 'allow' => true, + 'roles' => ['@'], + ], + // everything else is denied + ], + ], + ]; + } + + /** + * Lists all Card models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new CardSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Card model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Card model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Card(); + $model->status = Card::STATUS_ACTIVE; + $model->type = Card::TYPE_RFID; + if ($model->load(Yii::$app->request->post()) && $model->save()) { + \Yii::$app->session->setFlash( 'success','Card created!' ); + if ( isset($_POST['create_next'])){ + return $this->redirect(['create' ]); + }else{ + return $this->redirect(['view', 'id' => $model->id_card]); + } + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Card model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_card]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Card model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Card model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Card the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Card::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + + /** + * Your controller action to fetch the list + */ + public function actionList($search = null) { + $query = new Query(); + + $query->select ( [ + 'card.number as number', + 'customer.name as name', + "concat( card.number , case when customer.name is null then '' else customer.name end ) as txt ", + ] )->from (Card::tableName() )->join("left join", Customer::tableName(), 'card.id_card = customer.id_customer_card')->where ( ' lower(number) LIKE "%' . strtolower ( $search ) . '%"' )->orderBy ( 'number' ) ; + + if ( isset($_GET['onlyFree']) && $_GET['onlyFree'] == '1'){ + $query->andWhere( 'customer.id_customer is null' ); + } + + $command = $query->createCommand (); + $data = $command->queryAll (); + $out = [ ]; + foreach ( $data as $d ) { + $out [] = [ + 'number' => $d ['number'], + 'name' => $d ['name'], + 'txt' => $d ['txt'], + ]; + } + echo Json::encode ( $out ); + } + + + +} diff --git a/backend/controllers/CityController.php b/backend/controllers/CityController.php new file mode 100644 index 0000000..4437598 --- /dev/null +++ b/backend/controllers/CityController.php @@ -0,0 +1,179 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => [ 'create','index','view','update','name-list','zip-list'], + 'allow' => true, + 'roles' => ['@'], + ], + // everything else is denied + ], + ], + ]; + } + + + /** + * Lists all City models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new CitySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single City model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new City model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new City(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_city]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing City model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_city]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing City model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the City model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return City the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = City::findOne($id)) !== null) { + return $model; + } else { + 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', + 'concat( zip, \' \', name) as fullname' + ] )->from (City::tableName() )->where ( ' lower(name) LIKE "%' . strtolower ( $search ) . '%"' )->orderBy ( 'name' )->groupBy('name')->limit(20); + $command = $query->createCommand (); + $data = $command->queryAll (); + $out = [ ]; + foreach ( $data as $d ) { + $out [] = [ + 'name' => $d ['name'], + 'zip' => $d ['zip'], + 'fullname' => $d ['fullname'], + ]; + } + echo Json::encode ( $out ); + } + /** + * Your controller action to fetch the list + */ + public function actionZipList($search = null) { + $query = new Query(); + + $query->select ( [ + 'name', + 'min(zip) as zip', + 'concat( zip, \' \', name) as fullname' + ] )->from (City::tableName() )->where ( ' lower(zip) LIKE "%' . strtolower ( $search ) . '%"' )->orderBy ( 'name' )->groupBy('name')->limit(20); + $command = $query->createCommand (); + $data = $command->queryAll (); + $out = [ ]; + foreach ( $data as $d ) { + $out [] = [ + 'name' => $d ['name'], + 'zip' => $d ['zip'], + 'fullname' => $d ['fullname'], + ]; + } + echo Json::encode ( $out ); + } +} diff --git a/backend/controllers/CollectionController.php b/backend/controllers/CollectionController.php new file mode 100644 index 0000000..6db22eb --- /dev/null +++ b/backend/controllers/CollectionController.php @@ -0,0 +1,97 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => [ 'index','view' ], + 'allow' => true, + 'roles' => ['@'], + ], + // everything else is denied + ], + ], + ]; + } + + /** + * Lists all Collection models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new CollectionSearch(); + $searchModel->accounts = Account::read(); + $searchModel->accountMap = Account::toAccaountMap($searchModel->accounts); + + $searchModel->users = User::read(); + + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + $searchModel->searchTotal(); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Collection model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + + $model = $this->findModel($id); + + $accounts = Account::read(); + $accountMap = Account::toAccaountMap($accounts); + + $totals = Transfer::mkTotals($model->start, $model->end, $model->id_user, null, $model->id_account, $accounts, $accountMap); + return $this->render('view', [ + 'model' => $model, + 'totals' => $totals, + ]); + } + + + /** + * Finds the Collection model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Collection the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Collection::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/CurrencyController.php b/backend/controllers/CurrencyController.php new file mode 100644 index 0000000..f21e26f --- /dev/null +++ b/backend/controllers/CurrencyController.php @@ -0,0 +1,98 @@ +search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Currency model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Currency model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Currency(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_currency]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Currency model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_currency]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + + /** + * Finds the Currency model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Currency the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Currency::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/CustomerController.php b/backend/controllers/CustomerController.php new file mode 100644 index 0000000..c1482af --- /dev/null +++ b/backend/controllers/CustomerController.php @@ -0,0 +1,122 @@ +search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Customer model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Customer model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + 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]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Customer model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + 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]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Customer model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + */ + /** + * Finds the Customer model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Customer the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Customer::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/DiscountController.php b/backend/controllers/DiscountController.php new file mode 100644 index 0000000..1b7b4f0 --- /dev/null +++ b/backend/controllers/DiscountController.php @@ -0,0 +1,124 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => [ 'index','view' ], + 'allow' => true, + 'roles' => ['admin','employee','reception'], + ], + [ + 'actions' => ['create','update'], + 'allow' => true, + 'roles' => ['admin' ], + ], + // everything else is denied + ], + ], + ]; + } + + + /** + * Lists all Discount models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new DiscountSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Discount model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Discount model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Discount(); + + $model->status = Discount::STATUS_ACTIVE; + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_discount]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Discount model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_discount]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + + /** + * Finds the Discount model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Discount the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Discount::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/ProcurementController.php b/backend/controllers/ProcurementController.php new file mode 100644 index 0000000..1acb89d --- /dev/null +++ b/backend/controllers/ProcurementController.php @@ -0,0 +1,232 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => ['create','index','view', 'create-product'], + 'allow' => true, + 'roles' => ['@'], + ], + // everything else is denied + ], + ], + ]; + } + + + /** + * Lists all Procurement models. + * @return mixed + */ + public function actionIndex() + { + + $warehouses = Warehouse::read(null); + $products = Product::read(null); + $users = User::read(null); + + $searchModel = new ProcurementSearch(); + + $today = time(); + $tomorrow = time()+86400; + $searchModel->timestampStart = date("Y-m-d" , $today ); + $searchModel->timestampEnd = date("Y-m-d" , $tomorrow ); + $searchModel->date_start = Yii::$app->formatter->asDate($today); + $searchModel->date_end = Yii::$app->formatter->asDate($tomorrow); + + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'users' => $users, + 'products' => $products, + 'warehouses' => $warehouses, + ]); + } + + /** + * Displays a single Procurement model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Procurement model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Procurement(); + $model->scenario = 'create_general'; + + $model->id_user = Yii::$app->user->id; + + $warehouses = Warehouse::read(null); + + if ( count($warehouses) <= 0 ){ + throw new NotFoundHttpException( Yii::t('common/procurement' ,'No active warehouse found.' )); + } + + if ($model->load(Yii::$app->request->post()) && $model->validate()) { + + $connection = \Yii::$app->db; + + $transaction = $connection->beginTransaction(); + + try { + + $product = Product::findOne( $model->id_product ); + $model->stock = $product->stock; + $result = $model->save(false); + + $product->stock = $product->stock + $model->count; + $result &= $product->save(false); + + if ($result) { + $transaction->commit(); + } else { + $transaction->rollback(); + Helper::flash('error', "Hiba történt!"); + throw new NotFoundHttpException( Yii::t('common/procurement' ,'Failed to fullfill procurement.' )); + } + Helper::flash('success', Yii::t('backend/procurement', 'Beszerzés mentve')); + } catch (\Exception $e) { + $transaction->rollback(); + throw $e; + } + + + if ( isset($_POST['_next'])){ + return $this->redirect(['create' ]); + }else{ + return $this->redirect(['index' ]); + } + } else { + return $this->render('create', [ + 'model' => $model, + 'warehouses' =>$warehouses + ]); + } + } + /** + * Creates a new Procurement model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreateProduct($id) + { + + $product = $this->findProduct($id); + + $model = new Procurement(); + + $warehouses = Warehouse::read(null); + + $model->id_user = Yii::$app->user->id; + $model->id_product = $product->id_product; + $model->stock = $product->stock; + + $warehouses = Warehouse::read(null); + + if ( count($warehouses) <= 0 ){ + throw new NotFoundHttpException( Yii::t('common/procurement' ,'No active warehouse found.' )); + } + + if ($model->load(Yii::$app->request->post()) && $model->validate()) { + + $connection = \Yii::$app->db; + + $transaction = $connection->beginTransaction(); + + try { + + $result = $model->save(false); + + $product->stock = $product->stock + $model->count; + $result &= $product->save(false); + + if ($result) { + $transaction->commit(); + } else { + $transaction->rollback(); + } + } catch (\Exception $e) { + $transaction->rollback(); + throw $e; + } + + + return $this->redirect(['view', 'id' => $model->id_procurement]); + } else { + return $this->render('create_product', [ + 'model' => $model, + 'warehouses' =>$warehouses, + 'product' => $product + ]); + } + } + + /** + * Finds the Procurement model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Procurement the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Procurement::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + /** + * Finds the Product model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Procurement the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findProduct($id) + { + if (($model = Product::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/ProductCategoryController.php b/backend/controllers/ProductCategoryController.php new file mode 100644 index 0000000..5ed8385 --- /dev/null +++ b/backend/controllers/ProductCategoryController.php @@ -0,0 +1,98 @@ +search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single ProductCategory model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new ProductCategory model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new ProductCategory(); + $model->status = ProductCategory::STATUS_ACTIVE; + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_product_category]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing ProductCategory model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_product_category]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + + /** + * Finds the ProductCategory model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return ProductCategory the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = ProductCategory::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/ProductController.php b/backend/controllers/ProductController.php new file mode 100644 index 0000000..178fd0f --- /dev/null +++ b/backend/controllers/ProductController.php @@ -0,0 +1,125 @@ +search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Product model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Product model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Product(); + $model->stock = 0; + $model->status = Product::STATUS_ACTIVE; + $accounts = Account::read(null); + $categories = ProductCategory::read(null); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_product]); + } else { + return $this->render('create', [ + 'model' => $model, + 'accounts' => $accounts, + 'categories' => $categories , + + ]); + } + } + + /** + * Updates an existing Product model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + $accounts = Account::readAccounts($model->id_account); + $categories = ProductCategory::read($model->id_product_category); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_product]); + } else { + return $this->render('update', [ + 'model' => $model, + 'accounts' => $accounts, + 'categories' => $categories , + ]); + } + } + + /** + * Deletes an existing Product model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Product model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Product the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Product::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/TicketController.php b/backend/controllers/TicketController.php new file mode 100644 index 0000000..9c80307 --- /dev/null +++ b/backend/controllers/TicketController.php @@ -0,0 +1,121 @@ +search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Ticket model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Ticket model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Ticket(); + + $discounts = Discount::read(); + $ticketTypes = TicketType::read(); + $accounts = Account::readAccounts(); + + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_ticket]); + } else { + return $this->render('create', [ + 'model' => $model, + 'discounts' => $discounts, + 'ticketTypes' => $ticketTypes, + 'accounts' => $accounts, + ]); + } + } + + /** + * Updates an existing Ticket model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_ticket]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Ticket model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Ticket model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Ticket the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Ticket::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/TicketTypeController.php b/backend/controllers/TicketTypeController.php new file mode 100644 index 0000000..a1be1ab --- /dev/null +++ b/backend/controllers/TicketTypeController.php @@ -0,0 +1,133 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => [ 'index','view'], + 'allow' => true, + 'roles' => ['admin','employee','reception'], + ], + [ + 'actions' => ['create' , 'update'], + 'allow' => true, + 'roles' => ['admin' ], + ], + // everything else is denied + ], + ], + ]; + } + + + /** + * Lists all TicketType models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TicketTypeSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single TicketType model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new TicketType model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new TicketType(); + + $model->type = TicketType::TYPE_DEFAULT; + $model->status = TicketType::STATUS_ACTIVE; + $model->time_unit_type = TicketType::TIME_UNIT_MONTH; + $model->time_unit_count = 1; + $model->max_usage_count = 0; + $accounts = Account::find()->andWhere(['status' => Account::STATUS_ACTIVE])->all(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_ticket_type]); + } else { + return $this->render('create', [ + 'model' => $model, + 'accounts' => $accounts + ]); + } + } + + /** + * Updates an existing TicketType model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $accounts = Account::find()->andWhere( ['or', ['status' => Account::STATUS_ACTIVE], ['id_account' => $model->id_account] ])->all(); + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_ticket_type]); + } else { + return $this->render('update', [ + 'model' => $model, + 'accounts' => $accounts + ]); + } + } + + + /** + * Finds the TicketType model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return TicketType the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = TicketType::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/TransferController.php b/backend/controllers/TransferController.php new file mode 100644 index 0000000..17327b5 --- /dev/null +++ b/backend/controllers/TransferController.php @@ -0,0 +1,108 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => [ 'index','view' ], + 'allow' => true, + 'roles' => ['admin','employee','reception'], + ], + // everything else is denied + ], + ], + ]; + } + + + /** + * Lists all Transfer models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TransferSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + $accounts = Account::read(); + + $searchModel->totalsTransfers(); + + $users = User::read(); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'accounts' => $accounts, + 'users' => $users, + ]); + } + + /** + * Displays a single Transfer model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + + /** + * Updates an existing Transfer model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_transfer]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + */ + + /** + * Finds the Transfer model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Transfer the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Transfer::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/UserController.php b/backend/controllers/UserController.php new file mode 100644 index 0000000..6a41097 --- /dev/null +++ b/backend/controllers/UserController.php @@ -0,0 +1,195 @@ + [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + // allow authenticated users + [ + 'actions' => [ 'index','view' ], + 'allow' => true, + 'roles' => ['employee','admin','reception'], + ], + // allow authenticated users + [ + 'actions' => [ 'create', 'update'], + 'allow' => true, + 'roles' => ['admin'], + ], + // everything else is denied + ], + ], + ]; + } + + + /** + * Lists all User models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new UserSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single User model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new User model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + 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 ){ + echo "saving account"; + $uaa = new UserAccountAssignment(); + $uaa->id_user = $model->id; + $uaa->id_account = $id_account; + $uaa->save(); + } + + } + + /** + * Updates an existing User model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + 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')){ + $model->role = 'employee'; + }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); + return $this->redirect(['view', 'id' => $model->id]); + } else { + } + return $this->render('update', [ + 'model' => $model, + 'accounts' => $accounts, + ]); + } + + private function applyAccounts($model ){ + $assignedAccounts = $model->userAccountAssignments; + foreach ($assignedAccounts as $acc ){ + $model->selected_accounts[] = $acc->id_account; + } + } + + /** + * Deletes an existing User model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + + $user = $this->findModel($id); + + $user->updateAttributes(['status' => User::STATUS_DELETED]); + + return $this->redirect(['index']); + } + + /** + * Finds the User model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return User the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = User::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/WarehouseController.php b/backend/controllers/WarehouseController.php new file mode 100644 index 0000000..b0a1cc6 --- /dev/null +++ b/backend/controllers/WarehouseController.php @@ -0,0 +1,114 @@ +search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Warehouse model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Warehouse model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Warehouse(); + $model->status = Warehouse::STATUS_ACTIVE; + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_warehouse]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Warehouse model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_warehouse]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Warehouse model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ +// public function actionDelete($id) +// { +// $warehouse = $this->findModel($id); + +// $warehouse->updateAttributes(['status' => Warehouse::STATUS_DELETED]); + + +// return $this->redirect(['index']); +// } + + /** + * Finds the Warehouse model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Warehouse the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Warehouse::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/models/AccountSearch.php b/backend/models/AccountSearch.php new file mode 100644 index 0000000..63095d3 --- /dev/null +++ b/backend/models/AccountSearch.php @@ -0,0 +1,77 @@ +innerJoin("user_account_assignment",'account.id_account = user_account_assignment.id_account' ); + $query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]); + } + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_account' => $this->id_account, + 'status' => $this->status, + 'type' => $this->type, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/models/AccountStateSearch.php b/backend/models/AccountStateSearch.php new file mode 100644 index 0000000..c11b175 --- /dev/null +++ b/backend/models/AccountStateSearch.php @@ -0,0 +1,89 @@ + 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = AccountState::find(); + + + 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 ]); + } + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + 'sort' => false, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + $query->where('0=1'); + return $dataProvider; + } + + $query->orderBy(['created_at' => SORT_DESC]); + + $query->andFilterWhere([ + 'id_user' => $this->id_user, + 'id_account' => $this->id_account, + 'type' => $this->type, + ]); + + $query->andFilterWhere([ '>=', 'created_at', $this->timestampStart ] ); + $query->andFilterWhere([ '<', 'created_at', $this->timestampEnd ] ); + + return $dataProvider; + } +} diff --git a/backend/models/CardSearch.php b/backend/models/CardSearch.php new file mode 100644 index 0000000..3ae466e --- /dev/null +++ b/backend/models/CardSearch.php @@ -0,0 +1,88 @@ + $query, + ]); + + $dataProvider->sort ->attributes['customerName'] =[ + 'asc' => ['customer.name' => SORT_ASC ], + 'desc' => ['customer.name' => SORT_DESC ], + ]; + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->leftJoin(Customer::tableName(), 'customer.id_customer_card = card.id_card'); + + $query->andFilterWhere([ + 'card.status' => $this->status, + 'card.type' => $this->type, + ]); + + $query->andFilterWhere(['like', 'card.number', $this->number]); + $query->andFilterWhere(['like', 'customer.name', $this->searchCustomerName]); + + return $dataProvider; + } + + public function attributeLabels(){ + $result = parent::attributeLabels(); + $result +=[ + 'searchCustomerName' => Yii::t('common/card','Customer') + ]; + return $result; + } + +} diff --git a/backend/models/CitySearch.php b/backend/models/CitySearch.php new file mode 100644 index 0000000..8b49ee4 --- /dev/null +++ b/backend/models/CitySearch.php @@ -0,0 +1,76 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_city' => $this->id_city, + 'latitude' => $this->latitude, + 'longitude' => $this->longitude, + 'cso_code' => $this->cso_code, + 'rig_id' => $this->rig_id, + 'range' => $this->range, + 'population' => $this->population, + 'homes' => $this->homes, + ]); + + $query->andFilterWhere(['like', 'zip', $this->zip]) + ->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'city_code', $this->city_code]); + + return $dataProvider; + } +} diff --git a/backend/models/CollectionSearch.php b/backend/models/CollectionSearch.php new file mode 100644 index 0000000..a07a715 --- /dev/null +++ b/backend/models/CollectionSearch.php @@ -0,0 +1,92 @@ +Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], + [[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], + [['id_account','id_user'],'integer'] + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Collection::find(); + + + 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 ]); + } + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'collection.id_user' => $this->id_user, + 'collection.id_account' => $this->id_account, + ]); + + Helper::inInterval($query, 'collection.end', $this->timestampStart, $this->timestampEnd); + + return $dataProvider; + } + + public function searchTotal(){ + $this->totals = Collection::mkReceptionTotal($this->timestampStart, $this->timestampEnd , Yii::$app->user->id, [Collection::TYPE_RECEPTION], $this->id_account, $this->accounts, $this->accountMap); + } + +} diff --git a/backend/models/CurrencySearch.php b/backend/models/CurrencySearch.php new file mode 100644 index 0000000..10d7906 --- /dev/null +++ b/backend/models/CurrencySearch.php @@ -0,0 +1,70 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_currency' => $this->id_currency, + 'rate' => $this->rate, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'currency', $this->currency]) + ->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/models/CustomerCreate.php b/backend/models/CustomerCreate.php new file mode 100644 index 0000000..2f00b07 --- /dev/null +++ b/backend/models/CustomerCreate.php @@ -0,0 +1,135 @@ + 10], + [['cardNumber'], 'validateCustomerCard' ], + + [['partnerCardNumber'], 'string', 'max' => 10], + [['partnerCardNumber'], 'validatePartnerCard' ], + + [['name'], 'required' ], + [['name'], 'string', 'max' => 128], + + [['email'], 'string', 'max' => 255], + [['email'], 'email' ], + [['email'], 'unique' ], + [['email'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty($model->phone) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/backend','E-mail or phone number required!') + ], + + + [['password_plain','password_repeat'], 'string', 'max' => 32], + + [['sex'], 'integer'], + + [[ 'birthdate', ], 'date' ], + [[ 'date_stundent_card_expire', ], 'date' ], + + [[ 'description', 'address'], 'string', 'max' => 255], + + [['phone', 'tax_number', 'country'], 'string', 'max' => 20], + + [['phone'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty( $model->email ) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/backend','E-mail or phone number required!') + ], + + [['zip'], 'string', 'max' => 8], + + [['city'], 'string', 'max' => 30] + ]; + } + + + public function validateCustomerCard($a,$p){ + $card = null; + + if ( !empty($this->cardNumber)){ + $card = Card::readCard($this->cardNumber,true); + } + + if ( $card == null ){ + $this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám")); + }else{ + $this->id_customer_card = $card->id_card; + } + +// $this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám")); + } + + public function validatePartnerCard($a,$p){ + if ( !empty($this->partnerCardNumber) ){ + $card = Card::readCard($this->partnerCardNumber,true); + if ( $card == null ){ + $this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám")); + }else{ + $this->id_partner_card = $card->id_card; + } + } + } + +} diff --git a/backend/models/CustomerSearch.php b/backend/models/CustomerSearch.php new file mode 100644 index 0000000..199fd04 --- /dev/null +++ b/backend/models/CustomerSearch.php @@ -0,0 +1,117 @@ + $query, + ]); + + $dataProvider->sort ->attributes['customerCardNumber'] =[ + 'asc' => ['card.number' => SORT_ASC ], + 'desc' => ['card.number' => SORT_DESC ], + ]; + $dataProvider->sort->defaultOrder = [ + 'name' => SORT_ASC, + ]; + + +// $dataProvider->setSort( + + +// [ +// 'attributes' => [ +// 'id', +// 'fullName' => [ +// 'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], +// 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC], +// 'label' => 'Full Name', +// 'default' => SORT_ASC +// ], +// 'country_id' +// ] +// ]); + + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->leftJoin(Card::tableName(), " customer.id_customer_card = card.id_card" ); + +// $query->andFilterWhere([ +// 'id_customer' => $this->id_customer, +// 'id_customer_card' => $this->id_customer_card, +// 'id_user' => $this->id_user, +// 'id_partner_card' => $this->id_partner_card, +// 'id_proposer' => $this->id_proposer, +// 'sex' => $this->sex, +// 'date_stundent_card_expire' => $this->date_stundent_card_expire, +// 'birthdate' => $this->birthdate, +// 'created_at' => $this->created_at, +// 'updated_at' => $this->updated_at, +// ]); + + $query->andFilterWhere(['like', 'customer.name', $this->name]) + ->andFilterWhere(['like', 'customer.email', $this->email]) + ->andFilterWhere(['like', 'card.number', $this->cardNumber]) + ->andFilterWhere(['like', 'address', $this->address]); + + return $dataProvider; + } + + public function attributeLabels( ) { + $labels = parent::attributeLabels(); + return $labels; + } +} diff --git a/backend/models/CustomerUpdate.php b/backend/models/CustomerUpdate.php new file mode 100644 index 0000000..cef9ec9 --- /dev/null +++ b/backend/models/CustomerUpdate.php @@ -0,0 +1,115 @@ + 10], +// [['cardNumber'], 'validateCustomerCard' ], + + [['partnerCardNumber'], 'string', 'max' => 10], + [['partnerCardNumber'], 'validatePartnerCard' ], + + [['name'], 'required' ], + [['name'], 'string', 'max' => 128], + + [['email'], 'string', 'max' => 255], + [['email'], 'email' ], + [['email'], 'unique' ], + + [['email'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty($model->phone) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/backend','E-mail or phone number required!') + ], + + + [['password_plain','password_repeat'], 'string', 'max' => 32], + + [['sex'], 'integer'], + + [[ 'birthdate', ], 'date' ], + [[ 'date_stundent_card_expire', ], 'date' ], + + [[ 'description', 'address'], 'string', 'max' => 255], + + [['phone', 'tax_number', 'country'], 'string', 'max' => 20], + + [['phone'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty( $model->email ) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/backend','E-mail or phone number required!') + ], + + [['zip'], 'string', 'max' => 8], + + [['city'], 'string', 'max' => 30] + ]; + } + + + public function validateCustomerCard($a,$p){ +// Customer::find()->andWhere( [$this->cardNumber ) + } + public function validatePartnerCard($a,$p){ +// Customer::find()->andWhere( [$this->cardNumber ) + } + +} diff --git a/backend/models/DiscountSearch.php b/backend/models/DiscountSearch.php new file mode 100644 index 0000000..0a2f640 --- /dev/null +++ b/backend/models/DiscountSearch.php @@ -0,0 +1,71 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_discount' => $this->id_discount, + 'status' => $this->status, + 'type' => $this->type, + 'value' => $this->value, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/models/ProcurementSearch.php b/backend/models/ProcurementSearch.php new file mode 100644 index 0000000..6e6a42c --- /dev/null +++ b/backend/models/ProcurementSearch.php @@ -0,0 +1,91 @@ + 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + [[ 'date_end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Procurement::find(); + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + if ( RoleDefinition::isReception()){ + $query->andWhere(['id_user' => Yii::$app->user->id ]); + } + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + + if ( empty($this->date_start) ){ + $this->timestampStart = ''; + } + if ( empty($this->date_end) ){ + $this->timestampEnd = ''; + } + + $query->andFilterWhere([ + 'id_warehouse' => $this->id_warehouse, + 'id_user' => $this->id_user, + 'id_product' => $this->id_product, + ]); + + $query->andFilterWhere([ '>=', 'created_at', $this->timestampStart ] ); + $query->andFilterWhere([ '<', 'created_at', $this->timestampEnd ] ); + + + return $dataProvider; + } +} diff --git a/backend/models/ProductCategorySearch.php b/backend/models/ProductCategorySearch.php new file mode 100644 index 0000000..ff747f3 --- /dev/null +++ b/backend/models/ProductCategorySearch.php @@ -0,0 +1,69 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_product_category' => $this->id_product_category, + 'status' => $this->status, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/models/ProductSearch.php b/backend/models/ProductSearch.php new file mode 100644 index 0000000..44319eb --- /dev/null +++ b/backend/models/ProductSearch.php @@ -0,0 +1,75 @@ +innerJoin("user_account_assignment",'product.id_account = user_account_assignment.id_account' ); + $query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]); + } + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'product.id_product_category' => $this->id_product_category, + 'product.id_account' => $this->id_account, + 'product.status' => $this->status, + ]); + + $query->andFilterWhere(['like', 'product_number', $this->product_number]) + ->andFilterWhere(['like', 'barcode', $this->barcode]); + + return $dataProvider; + } +} diff --git a/backend/models/TicketSearch.php b/backend/models/TicketSearch.php new file mode 100644 index 0000000..19d5813 --- /dev/null +++ b/backend/models/TicketSearch.php @@ -0,0 +1,78 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_ticket' => $this->id_ticket, + 'id_user' => $this->id_user, + 'id_ticket_type' => $this->id_ticket_type, + 'id_account' => $this->id_account, + 'id_discount' => $this->id_discount, + 'start' => $this->start, + 'end' => $this->end, + 'max_usage_count' => $this->max_usage_count, + 'usage_count' => $this->usage_count, + 'status' => $this->status, + 'price_brutto' => $this->price_brutto, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'comment', $this->comment]); + + return $dataProvider; + } +} diff --git a/backend/models/TicketTypeSearch.php b/backend/models/TicketTypeSearch.php new file mode 100644 index 0000000..5749c34 --- /dev/null +++ b/backend/models/TicketTypeSearch.php @@ -0,0 +1,76 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_ticket_type' => $this->id_ticket_type, + 'type' => $this->type, + 'max_usage_count' => $this->max_usage_count, + 'time_unit_type' => $this->time_unit_type, + 'time_unit_count' => $this->time_unit_count, + 'price_brutto' => $this->price_brutto, + 'id_account' => $this->id_account, + 'flag_student' => $this->flag_student, + 'status' => $this->status, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/models/TransferSearch.php b/backend/models/TransferSearch.php new file mode 100644 index 0000000..c76bc00 --- /dev/null +++ b/backend/models/TransferSearch.php @@ -0,0 +1,127 @@ + 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + ['types', 'each', 'rule' => ['integer']], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Transfer::find(); + + + if ( !RoleDefinition::isAdmin() ){ + $query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' ); + $query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]); + } + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + + $query->addSelect( ['*' ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'transfer.id_account' => $this->id_account, + 'transfer.type' => $this->type, + 'transfer.id_user' => $this->id_user, + ]); + + $created_condition = ['and',[ '>=', 'transfer.created_at', $this->timestampStart ] ,[ '<', 'transfer.created_at', $this->timestampEnd ] ]; + $paid_condition = ['and',[ '>=', 'transfer.paid_at', $this->timestampStart ] ,[ '<', 'transfer.paid_at', $this->timestampEnd ] ]; + + $query->andFilterWhere(['or' , $created_condition , $paid_condition]); + + return $dataProvider; + } + + + public function totalsTransfers( ){ + $accountTotals = []; + $fullTotal = [ + 'label' => Yii::t('common/transfer', 'Total'), + 'money' => 0 + ]; + + + $accounts = Account::read(); + $accountMap = ArrayHelper::map( $accounts ,'id_account','name' ); + $idUser = Yii::$app->user->id; + + $this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap); + + + } + + + + +} diff --git a/backend/models/UserCreate.php b/backend/models/UserCreate.php new file mode 100644 index 0000000..710765c --- /dev/null +++ b/backend/models/UserCreate.php @@ -0,0 +1,79 @@ +$attribute)) { + $this->addError($attribute, 'Invalid array'); + } + } + ], + ['email' ,'email' ], + ['email' ,'unique' ], + ['username' ,'unique' ], + [['password_plain' ,'password_repeat'] ,'string','min' =>6 ], + [['password_repeat'] ,'validatePasswordRepeat' ], + + [['role'], 'required'], + [['role'], 'string', 'max' => 20], + ]; + } + + public function validatePasswordRepeat($attribute,$params){ + + if ( !$this->hasErrors()){ + if ( $this->password_plain != $this->password_repeat ){ + $this->addError($attribute, Yii::t('app', 'Jelszó és jelszó újra nem egyezik!') ); + } + } + } + + public function attributeLabels(){ + return [ + + 'email' =>'E-mail', + 'username' =>'Felhasználónév', + 'created_at' =>'Létrehozás dátuma', + 'password_plain' => Yii::t('app','Jelszó'), + 'password_repeat' => Yii::t('app','Jelszó újra'), + + ]; + } + + public function beforeSave($insert){ + if ( parent::beforeSave($insert)){ + if ( $insert ){ + $this->setPassword($this->password_plain); + $this->generateAuthKey(); + return true; + } + }else{ + return false; + } + } + + public function afterSave($insert, $changedAttributes){ + parent::afterSave($insert, $changedAttributes); + $am = Yii::$app->authManager; + $role = $am->getRole($this->role); + Yii::$app->authManager->assign($role, $this->id); + } + +} \ No newline at end of file diff --git a/backend/models/UserSearch.php b/backend/models/UserSearch.php new file mode 100644 index 0000000..bbf528d --- /dev/null +++ b/backend/models/UserSearch.php @@ -0,0 +1,77 @@ + $query, + ]); + + $query->andWhere(['status' => User::STATUS_ACTIVE]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + + + $query->andFilterWhere([ + 'id' => $this->id, + 'status' => $this->status, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'username', $this->username]) + ->andFilterWhere(['like', 'auth_key', $this->auth_key]) + ->andFilterWhere(['like', 'password_hash', $this->password_hash]) + ->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token]) + ->andFilterWhere(['like', 'email', $this->email]); + + return $dataProvider; + } +} diff --git a/backend/models/UserUpdate.php b/backend/models/UserUpdate.php new file mode 100644 index 0000000..03a47f8 --- /dev/null +++ b/backend/models/UserUpdate.php @@ -0,0 +1,82 @@ + User::className(), 'targetAttribute' => 'email'], + ['username' ,'unique', 'targetClass' => User::className(), 'targetAttribute' => 'username'], + [['password_plain' ,'password_repeat'] ,'string','min' =>6 ], + [['password_repeat'] ,'validatePasswordRepeat' ], + ['selected_accounts',function ($attribute, $params) { + if (!is_array($this->$attribute)) { + $this->addError($attribute, 'Invalid array'); + } + } + ], + [['role'], 'required'], + [['role'], 'string', 'max' => 20], + ]; + } + + /** + * @formatter:on + */ + public function validatePasswordRepeat($attribute, $params) { + if (! $this->hasErrors ()) { + if ( !empty($this->password_plain) || !empty($this->password_repeat) ){ + if ($this->password_plain != $this->password_repeat) { + $this->addError ( $attribute, Yii::t ( 'app', 'Jelszó és jelszó újra nem egyezik!' ) ); + } + } + } + } + public function attributeLabels() { + return [ + + 'email' => 'E-mail', + 'username' => 'Felhasználónév', + 'created_at' => 'Létrehozás dátuma', + 'password_plain' => Yii::t ( 'app', 'Jelszó' ), + 'password_repeat' => Yii::t ( 'app', 'Jelszó újra' ) + ] + ; + } + public function beforeSave($insert) { + if (parent::beforeSave ( $insert )) { + if (! $insert) { + if ( !empty( $this->password_plain ) ) { + $this->setPassword($this->password_plain); + return true; + } + } + return true; + } else { + return false; + } + } + public function afterSave($insert, $changedAttributes){ + parent::afterSave($insert, $changedAttributes); + $am = Yii::$app->authManager; + $am->revokeAll($this->id); + $role = $am->getRole($this->role); + Yii::$app->authManager->assign($role, $this->id); + } +} \ No newline at end of file diff --git a/backend/models/WarehouseSearch.php b/backend/models/WarehouseSearch.php new file mode 100644 index 0000000..18aa9f6 --- /dev/null +++ b/backend/models/WarehouseSearch.php @@ -0,0 +1,69 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_warehouse' => $this->id_warehouse, + 'status' => $this->status, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/views/account-state/_form.php b/backend/views/account-state/_form.php new file mode 100644 index 0000000..806ef69 --- /dev/null +++ b/backend/views/account-state/_form.php @@ -0,0 +1,55 @@ + + +
+ + + + field($model, 'id_account')->textInput() ?> + + field($model, 'type')->textInput() ?> + + field($model, 'money')->textInput() ?> + + field($model, 'banknote_5_ft')->textInput() ?> + + field($model, 'banknote_10_ft')->textInput() ?> + + field($model, 'banknote_20_ft')->textInput() ?> + + field($model, 'banknote_50_ft')->textInput() ?> + + field($model, 'banknote_100_ft')->textInput() ?> + + field($model, 'banknote_200_ft')->textInput() ?> + + field($model, 'banknote_500_ft')->textInput() ?> + + field($model, 'banknote_1000_ft')->textInput() ?> + + field($model, 'banknote_2000_ft')->textInput() ?> + + field($model, 'banknote_5000_ft')->textInput() ?> + + field($model, 'banknote_10000_ft')->textInput() ?> + + field($model, 'banknote_20000_ft')->textInput() ?> + + field($model, 'comment')->textInput(['maxlength' => true]) ?> + + field($model, 'prev_state')->textInput() ?> + +
+ isNewRecord ? Yii::t('backend/account-state', 'Create') : Yii::t('backend/account-state', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/account-state/_item_view.php b/backend/views/account-state/_item_view.php new file mode 100644 index 0000000..7c58dce --- /dev/null +++ b/backend/views/account-state/_item_view.php @@ -0,0 +1,13 @@ + + + $model, + ]); +?> + + diff --git a/backend/views/account-state/_search.php b/backend/views/account-state/_search.php new file mode 100644 index 0000000..fe23edf --- /dev/null +++ b/backend/views/account-state/_search.php @@ -0,0 +1,68 @@ + + + 'Mind'] + HtmlHelper::mkAccountOptions($accounts); +$userOptions = ['' => 'Mind'] + HtmlHelper::mkOptions($users,'id','username') +?> + + diff --git a/backend/views/account-state/create.php b/backend/views/account-state/create.php new file mode 100644 index 0000000..b6e544c --- /dev/null +++ b/backend/views/account-state/create.php @@ -0,0 +1,21 @@ +title = Yii::t('backend/account-state', 'Create Account State'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/account-state', 'Account States'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/account-state/index.php b/backend/views/account-state/index.php new file mode 100644 index 0000000..e2a5fd9 --- /dev/null +++ b/backend/views/account-state/index.php @@ -0,0 +1,39 @@ +title = Yii::t('backend/account-state', 'Account States'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel,'accounts' => $accounts,'users' => $users,]); ?> + + + $dataProvider, + 'columns' => [ + + 'typeName', + 'money', + 'created_at:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' => '{view}' + ], + ], + ]); */?> + + $dataProvider, + 'itemView' => '_item_view' + ])?> + +
diff --git a/backend/views/account-state/update.php b/backend/views/account-state/update.php new file mode 100644 index 0000000..fe8cf6c --- /dev/null +++ b/backend/views/account-state/update.php @@ -0,0 +1,23 @@ +title = Yii::t('backend/account-state', 'Update {modelClass}: ', [ + 'modelClass' => 'Account State', +]) . ' ' . $model->id_account_state; +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/account-state', 'Account States'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id_account_state, 'url' => ['view', 'id' => $model->id_account_state]]; +$this->params['breadcrumbs'][] = Yii::t('backend/account-state', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/account-state/view.php b/backend/views/account-state/view.php new file mode 100644 index 0000000..61cc88e --- /dev/null +++ b/backend/views/account-state/view.php @@ -0,0 +1,56 @@ +title = $model->id_account_state; +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/account-state', 'Account States'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id_account_state], ['class' => 'btn btn-primary']) ?> + $model->id_account_state], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('backend/account-state', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id_account_state', + 'id_account', + 'type', + 'money', + 'banknote_5_ft', + 'banknote_10_ft', + 'banknote_20_ft', + 'banknote_50_ft', + 'banknote_100_ft', + 'banknote_200_ft', + 'banknote_500_ft', + 'banknote_1000_ft', + 'banknote_2000_ft', + 'banknote_5000_ft', + 'banknote_10000_ft', + 'banknote_20000_ft', + 'id_user', + 'created_at', + 'updated_at', + 'comment', + 'prev_state', + 'prev_money', + ], + ]) ?> + +
diff --git a/backend/views/account/_form.php b/backend/views/account/_form.php new file mode 100644 index 0000000..a4c110a --- /dev/null +++ b/backend/views/account/_form.php @@ -0,0 +1,29 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/account', "Active") ]) ?> + + field($model, 'type')->dropDownList(Account::types()) ?> + + +
+ isNewRecord ? Yii::t('common/account', 'Create') : Yii::t('common/account', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/account/_search.php b/backend/views/account/_search.php new file mode 100644 index 0000000..35b39c8 --- /dev/null +++ b/backend/views/account/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/views/account/create.php b/backend/views/account/create.php new file mode 100644 index 0000000..c30047a --- /dev/null +++ b/backend/views/account/create.php @@ -0,0 +1,21 @@ +title = Yii::t('common/account', 'Create Account'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/account', 'Accounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/account/index.php b/backend/views/account/index.php new file mode 100644 index 0000000..982ff19 --- /dev/null +++ b/backend/views/account/index.php @@ -0,0 +1,47 @@ +title = Yii::t('common/account', 'Accounts'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + + +

+ 'btn btn-success']) ?> +

+ + + $dataProvider, + 'columns' => [ + 'name', + [ + 'attribute' => 'status', + 'value' => 'statusHuman', + ], + [ + 'attribute' => 'type', + 'value' => 'typeHuman', + ], + 'created_at:datetime', + 'updated_at:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' => RoleDefinition::getRoleTemplate( ['admin' => '{view} {update}','employee' => '{view}' , 'reception' => '{view}']), + + ], + ], + ]); ?> + +
diff --git a/backend/views/account/update.php b/backend/views/account/update.php new file mode 100644 index 0000000..3510e0c --- /dev/null +++ b/backend/views/account/update.php @@ -0,0 +1,23 @@ +title = Yii::t('common/account', 'Update {modelClass}: ', [ + 'modelClass' => Yii::t('common/account', 'Account'), +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/account', 'Accounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_account]]; +$this->params['breadcrumbs'][] = Yii::t('common/account', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/account/view.php b/backend/views/account/view.php new file mode 100644 index 0000000..f277bd0 --- /dev/null +++ b/backend/views/account/view.php @@ -0,0 +1,42 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/account', 'Accounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + +

+ $model->id_account], ['class' => 'btn btn-primary']) ?> +

+ + + $model, + 'attributes' => [ + 'name', + [ + 'attribute' => 'status', + 'label' => Yii::t('common/account', "Active"), + 'value' => $model->statusHuman + ], + [ + 'attribute' => 'type', + 'value' => $model->typeHuman + ], + 'created_at:datetime', + 'updated_at:datetime', + ], + ]) ?> + +
diff --git a/backend/views/card/_form.php b/backend/views/card/_form.php new file mode 100644 index 0000000..dfa41b0 --- /dev/null +++ b/backend/views/card/_form.php @@ -0,0 +1,30 @@ + + +
+ + + + field($model, 'number')->textInput(['maxlength' => true]) ?> + + field($model, 'status')->dropDownList(Card::statuses()) ?> + + field($model, 'type')->dropDownList(Card::types()) ?> + + +
+ isNewRecord ? Yii::t('common/card', 'Create') : Yii::t('common/card', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> + 'btn btn-primary','name'=>'create_next']) ?> +
+ + + +
diff --git a/backend/views/card/_search.php b/backend/views/card/_search.php new file mode 100644 index 0000000..cf109b4 --- /dev/null +++ b/backend/views/card/_search.php @@ -0,0 +1,60 @@ + + Yii::t('common/product','All' ) ]; + + $o = $all + $options; + + return $o; +} + + +$typeOptions = mkOptions(Card::types()); +$statusOptions = mkOptions(Card::statuses()); + + +?> + diff --git a/backend/views/card/create.php b/backend/views/card/create.php new file mode 100644 index 0000000..ffe65db --- /dev/null +++ b/backend/views/card/create.php @@ -0,0 +1,21 @@ +title = Yii::t('common/card', 'Create Card'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/card/index.php b/backend/views/card/index.php new file mode 100644 index 0000000..94d6086 --- /dev/null +++ b/backend/views/card/index.php @@ -0,0 +1,52 @@ +title = Yii::t('common/card', 'Cards'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + [ + 'attribute' => 'number', + 'value' => 'number' + ], + [ + 'attribute' => 'status', + 'value' => 'statusHuman' + ], + [ + 'attribute' => 'type', + 'value' => 'typeHuman' + ], + [ + 'attribute' => 'customerName', + 'value' => 'customerName' + ], + 'updated_at:datetime', + + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{view}{update}' + ], + ], + ]); ?> + +
diff --git a/backend/views/card/update.php b/backend/views/card/update.php new file mode 100644 index 0000000..81ef1b8 --- /dev/null +++ b/backend/views/card/update.php @@ -0,0 +1,23 @@ +title = Yii::t('common/card', 'Update {modelClass}: ', [ + 'modelClass' => 'Card', +]) . ' ' . $model->id_card; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->number, 'url' => ['view', 'id' => $model->id_card]]; +$this->params['breadcrumbs'][] = Yii::t('common/card', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/card/view.php b/backend/views/card/view.php new file mode 100644 index 0000000..4ab4efd --- /dev/null +++ b/backend/views/card/view.php @@ -0,0 +1,32 @@ +title = Yii::t('common/card','Card: ').$model->number; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id_card], ['class' => 'btn btn-primary']) ?> +

+ + $model, + 'attributes' => [ + 'number', + ['attribute' => 'status', 'value' => $model->statusHuman], + ['attribute' => 'type', 'value' => $model->typeHuman], + 'created_at:datetime', + 'updated_at:datetime', + ], + ]) ?> + +
diff --git a/backend/views/city/_form.php b/backend/views/city/_form.php new file mode 100644 index 0000000..2bf34fb --- /dev/null +++ b/backend/views/city/_form.php @@ -0,0 +1,41 @@ + + +
+ + + + field($model, 'zip')->textInput(['maxlength' => true]) ?> + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'city_code')->textInput(['maxlength' => true]) ?> + + field($model, 'latitude')->textInput() ?> + + field($model, 'longitude')->textInput() ?> + + field($model, 'cso_code')->textInput() ?> + + field($model, 'rig_id')->textInput() ?> + + field($model, 'range')->textInput() ?> + + field($model, 'population')->textInput() ?> + + field($model, 'homes')->textInput() ?> + +
+ isNewRecord ? Yii::t('common/city', 'Create') : Yii::t('common/city', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/city/_search.php b/backend/views/city/_search.php new file mode 100644 index 0000000..79776f9 --- /dev/null +++ b/backend/views/city/_search.php @@ -0,0 +1,47 @@ + + + diff --git a/backend/views/city/create.php b/backend/views/city/create.php new file mode 100644 index 0000000..7ea4e8f --- /dev/null +++ b/backend/views/city/create.php @@ -0,0 +1,21 @@ +title = Yii::t('common/city', 'Create City'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/city', 'Cities'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/city/index.php b/backend/views/city/index.php new file mode 100644 index 0000000..da501fb --- /dev/null +++ b/backend/views/city/index.php @@ -0,0 +1,44 @@ +title = Yii::t('common/city', 'Cities'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id_city', + 'zip', + 'name', + 'city_code', + 'latitude', + // 'longitude', + // 'cso_code', + // 'rig_id', + // 'range', + // 'population', + // 'homes', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/backend/views/city/update.php b/backend/views/city/update.php new file mode 100644 index 0000000..6d35cc1 --- /dev/null +++ b/backend/views/city/update.php @@ -0,0 +1,23 @@ +title = Yii::t('common/city', 'Update {modelClass}: ', [ + 'modelClass' => 'City', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/city', 'Cities'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_city]]; +$this->params['breadcrumbs'][] = Yii::t('common/city', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/city/view.php b/backend/views/city/view.php new file mode 100644 index 0000000..7d2b8e9 --- /dev/null +++ b/backend/views/city/view.php @@ -0,0 +1,45 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/city', 'Cities'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id_city], ['class' => 'btn btn-primary']) ?> + $model->id_city], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('common/city', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id_city', + 'zip', + 'name', + 'city_code', + 'latitude', + 'longitude', + 'cso_code', + 'rig_id', + 'range', + 'population', + 'homes', + ], + ]) ?> + +
diff --git a/backend/views/collection/_form.php b/backend/views/collection/_form.php new file mode 100644 index 0000000..ca618e7 --- /dev/null +++ b/backend/views/collection/_form.php @@ -0,0 +1,39 @@ + + +
+ + + + field($model, 'id_user')->textInput() ?> + + field($model, 'created_by')->textInput() ?> + + field($model, 'id_account')->textInput() ?> + + field($model, 'money')->textInput() ?> + + field($model, 'start')->textInput() ?> + + field($model, 'end')->textInput() ?> + + field($model, 'type')->textInput() ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + +
+ isNewRecord ? Yii::t('backend/collection', 'Create') : Yii::t('backend/collection', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/collection/_search.php b/backend/views/collection/_search.php new file mode 100644 index 0000000..9ebdada --- /dev/null +++ b/backend/views/collection/_search.php @@ -0,0 +1,61 @@ + + +Yii::t('frontend/collection','All')]+ HtmlHelper::mkAccountOptions($model->accounts); +$userOptions = ['' =>Yii::t('frontend/collection','All')]+ ArrayHelper::map($model->users,'id','username'); + +?> + + diff --git a/backend/views/collection/create.php b/backend/views/collection/create.php new file mode 100644 index 0000000..fcef1e2 --- /dev/null +++ b/backend/views/collection/create.php @@ -0,0 +1,21 @@ +title = Yii::t('backend/collection', 'Create Collection'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/collection', 'Collections'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/collection/index.php b/backend/views/collection/index.php new file mode 100644 index 0000000..b056d51 --- /dev/null +++ b/backend/views/collection/index.php @@ -0,0 +1,63 @@ +title = Yii::t('backend/collection', 'Collections'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + + +
+
+ $searchModel->totals + ])?> +
+
+ + + $dataProvider, + 'columns' => [ + 'id_collection', + [ + 'attribute' => 'id_user', + 'value' => 'userName', + ], + [ + 'attribute' => 'id_account', + 'value' => 'accountName', + ], + 'money:integer', + [ + 'attribute' => 'start', + 'value' => function($model){ + return Yii::$app->formatter->asDatetime($model->start,'yyyy-MM-dd HH:mm:ss'); + } + ], + [ + 'attribute' => 'end', + 'value' => function($model){ + return Yii::$app->formatter->asDatetime($model->end,'yyyy-MM-dd HH:mm:ss'); + } + ], + 'created_at:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' => '{view}' + ], + ], + ]); ?> + +
diff --git a/backend/views/collection/update.php b/backend/views/collection/update.php new file mode 100644 index 0000000..eee672c --- /dev/null +++ b/backend/views/collection/update.php @@ -0,0 +1,23 @@ +title = Yii::t('backend/collection', 'Update {modelClass}: ', [ + 'modelClass' => 'Collection', +]) . ' ' . $model->id_collection; +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/collection', 'Collections'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id_collection, 'url' => ['view', 'id' => $model->id_collection]]; +$this->params['breadcrumbs'][] = Yii::t('backend/collection', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/collection/view.php b/backend/views/collection/view.php new file mode 100644 index 0000000..44a64a8 --- /dev/null +++ b/backend/views/collection/view.php @@ -0,0 +1,44 @@ +title = $model->id_collection; +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/collection', 'Collections'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + + + $model, + 'attributes' => [ + 'id_collection', + [ + 'attribute' =>'id_user', + 'value' => $model->userName + ], + [ + 'attribute' =>'id_account', + 'value' => $model->accountName + ], + 'money:integer', + 'start:datetime', + 'end:datetime', + 'created_at:datetime', + ], + ]) ?> + + $totals + ]); + ?> +
diff --git a/backend/views/currency/_form.php b/backend/views/currency/_form.php new file mode 100644 index 0000000..7e9f12b --- /dev/null +++ b/backend/views/currency/_form.php @@ -0,0 +1,28 @@ + + +
+ + + + field($model, 'currency')->textInput(['maxlength' => true]) ?> + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'rate')->textInput() ?> + + +
+ isNewRecord ? Yii::t('frontend/currency', 'Create') : Yii::t('frontend/currency', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/currency/_search.php b/backend/views/currency/_search.php new file mode 100644 index 0000000..d0a3166 --- /dev/null +++ b/backend/views/currency/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/views/currency/create.php b/backend/views/currency/create.php new file mode 100644 index 0000000..818df07 --- /dev/null +++ b/backend/views/currency/create.php @@ -0,0 +1,21 @@ +title = Yii::t('frontend/currency', 'Create Currency'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/currency/index.php b/backend/views/currency/index.php new file mode 100644 index 0000000..db7896b --- /dev/null +++ b/backend/views/currency/index.php @@ -0,0 +1,37 @@ +title = Yii::t('frontend/currency', 'Currencies'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'columns' => [ + 'currency', + 'name', + 'rate', +// 'created_at:datetime', + 'updated_at:datetime:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' =>'{view} {update}' + ], + ], + ]); ?> + +
diff --git a/backend/views/currency/update.php b/backend/views/currency/update.php new file mode 100644 index 0000000..6f2ebd8 --- /dev/null +++ b/backend/views/currency/update.php @@ -0,0 +1,23 @@ +title = Yii::t('frontend/currency', 'Update {modelClass}: ', [ + 'modelClass' => 'Currency', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_currency]]; +$this->params['breadcrumbs'][] = Yii::t('frontend/currency', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/currency/view.php b/backend/views/currency/view.php new file mode 100644 index 0000000..974115c --- /dev/null +++ b/backend/views/currency/view.php @@ -0,0 +1,32 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id_currency], ['class' => 'btn btn-primary']) ?> +

+ + $model, + 'attributes' => [ + 'currency', + 'name', + 'rate', + 'created_at:datetime', + 'updated_at:datetime', + ], + ]) ?> + +
diff --git a/backend/views/customer/_form.php b/backend/views/customer/_form.php new file mode 100644 index 0000000..004376f --- /dev/null +++ b/backend/views/customer/_form.php @@ -0,0 +1,61 @@ + + +
+ + + + field($model, 'id_customer_card')->textInput() ?> + + field($model, 'id_user')->textInput() ?> + + field($model, 'id_partner_card')->textInput() ?> + + field($model, 'id_proposer')->textInput() ?> + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'email')->textInput(['maxlength' => true]) ?> + + field($model, 'password')->passwordInput(['maxlength' => true]) ?> + + field($model, 'phone')->textInput(['maxlength' => true]) ?> + + field($model, 'sex')->textInput() ?> + + field($model, 'date_stundent_card_expire')->textInput() ?> + + field($model, 'birthdate')->textInput() ?> + + field($model, 'image')->textInput(['maxlength' => true]) ?> + + field($model, 'description')->textInput(['maxlength' => true]) ?> + + field($model, 'tax_number')->textInput(['maxlength' => true]) ?> + + field($model, 'country')->textInput(['maxlength' => true]) ?> + + field($model, 'zip')->textInput(['maxlength' => true]) ?> + + field($model, 'city')->textInput(['maxlength' => true]) ?> + + field($model, 'address')->textInput(['maxlength' => true]) ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + +
+ isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/customer/_form_create.php b/backend/views/customer/_form_create.php new file mode 100644 index 0000000..1b9949e --- /dev/null +++ b/backend/views/customer/_form_create.php @@ -0,0 +1,114 @@ + + +
+ + + + +
+
+ field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?> +
+
+ + +
+
+ field($model, 'name')->textInput(['maxlength' => true]) ?> +
+
+
+
+ field($model, 'email')->textInput(['maxlength' => true]) ?> +
+
+ +
+
+ field($model, 'sex')->dropDownList(Customer::sexes()) ?> +
+
+ field($model, 'birthdate')->widget(DatePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd' + ] + ]) ?> +
+
+ +
+
+ field($model, 'phone')->textInput(['maxlength' => true]) ?> +
+
+ field($model, 'date_stundent_card_expire')->widget(DatePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd' + ] + ]) ?> +
+
+ +
+
+ field($model, 'description')->textarea(['maxlength' => true]) ?> +
+
+ +
+
+ field($model, 'tax_number')->textInput(['maxlength' => true]) ?> +
+
+
+
+ field($model, 'country')->textInput(['maxlength' => true]) ?> +
+
+
+
+ field($model, 'zip')->widget(CityZipTypeahead::className(),[ + 'pluginEvents' =>[ + "typeahead:select" => "function(a,b) { + $('#customercreate-city').typeahead( 'val', b.name ); + }",] + ])?> +
+
+ field($model, 'city')->widget(CityNameTypeahead::className(),[ + 'pluginEvents' =>[ + "typeahead:select" => "function(a,b) { + $('#customercreate-zip').typeahead( 'val', b.zip ); + }",] + + ])?> +
+
+ + + + + field($model, 'address')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/customer/_form_update.php b/backend/views/customer/_form_update.php new file mode 100644 index 0000000..ed36c4e --- /dev/null +++ b/backend/views/customer/_form_update.php @@ -0,0 +1,118 @@ + + +
+ + + + +
+
+ field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?> + +
+ customerCardNumber ?> +
+
+
+ + +
+
+ field($model, 'name')->textInput(['maxlength' => true]) ?> +
+
+
+
+ field($model, 'email')->textInput(['maxlength' => true]) ?> +
+
+ +
+
+ field($model, 'sex')->dropDownList(Customer::sexes()) ?> +
+
+ field($model, 'birthdate')->widget(DatePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd' + ] + ]) ?> +
+
+ +
+
+ field($model, 'phone')->textInput(['maxlength' => true]) ?> +
+
+ field($model, 'date_stundent_card_expire')->widget(DatePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd' + ] + ]) ?> +
+
+ +
+
+ field($model, 'description')->textarea(['maxlength' => true]) ?> +
+
+ +
+
+ field($model, 'tax_number')->textInput(['maxlength' => true]) ?> +
+
+
+
+ field($model, 'country')->textInput(['maxlength' => true]) ?> +
+
+
+
+ field($model, 'zip')->widget(CityZipTypeahead::className(),[ + 'pluginEvents' =>[ + "typeahead:select" => "function(a,b) { + $('#customercreate-city').typeahead( 'val', b.name ); + }",] + ])?> +
+
+ field($model, 'city')->widget(CityNameTypeahead::className(),[ + 'pluginEvents' =>[ + "typeahead:select" => "function(a,b) { + $('#customercreate-zip').typeahead( 'val', b.zip ); + }",] + + ])?> +
+
+ + + + + field($model, 'address')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/customer/_search.php b/backend/views/customer/_search.php new file mode 100644 index 0000000..f455272 --- /dev/null +++ b/backend/views/customer/_search.php @@ -0,0 +1,38 @@ + + + diff --git a/backend/views/customer/create.php b/backend/views/customer/create.php new file mode 100644 index 0000000..eff48d7 --- /dev/null +++ b/backend/views/customer/create.php @@ -0,0 +1,21 @@ +title = Yii::t('common/customer', 'Create Customer'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form_create', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/customer/index.php b/backend/views/customer/index.php new file mode 100644 index 0000000..db4c9e4 --- /dev/null +++ b/backend/views/customer/index.php @@ -0,0 +1,56 @@ +title = Yii::t('common/customer', 'Customers'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'columns' => [ + [ + 'attribute' => 'customerCardNumber' , +// 'value' => 'customerCardNumber' + ], +// 'id_user', +// 'id_partner_card', +// 'id_proposer', + 'name', + 'email:email', + // 'password', + 'phone', + // 'sex', + // 'date_stundent_card_expire', + // 'birthdate', + // 'image', + // 'description', + // 'tax_number', + // 'country', + // 'zip', + // 'city', + // 'address', + 'created_at:datetime', + // 'updated_at', + + ['class' => 'yii\grid\ActionColumn', + 'template' =>'{view}{update}' + + ], + ], + ]); ?> + +
diff --git a/backend/views/customer/update.php b/backend/views/customer/update.php new file mode 100644 index 0000000..b0e396a --- /dev/null +++ b/backend/views/customer/update.php @@ -0,0 +1,23 @@ +title = Yii::t('common/customer', 'Update {modelClass}: ', [ + 'modelClass' => 'Customer', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_customer]]; +$this->params['breadcrumbs'][] = Yii::t('common/customer', 'Update'); +?> +
+ +

title) ?>

+ + render('_form_update', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/customer/view.php b/backend/views/customer/view.php new file mode 100644 index 0000000..7029491 --- /dev/null +++ b/backend/views/customer/view.php @@ -0,0 +1,56 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id_customer], ['class' => 'btn btn-primary']) ?> +

+ + $model, + 'attributes' => [ + [ + 'attribute' => 'id_customer_card', + 'value' => $model->customerCardNumber + ], + [ + 'attribute' => 'id_user', + 'value' => $model->username + ], + 'id_partner_card', + 'id_proposer', + 'name', + 'email:email', + 'password', + 'phone', + [ + 'attribute' => 'sex', + 'value' => $model->sexHuman + ], + 'date_stundent_card_expire', + 'birthdate:date', + 'image', + 'description', + 'tax_number', + 'country', + 'zip', + 'city', + 'address', + 'created_at:datetime', + 'updated_at:datetime', + ], + ]) ?> + +
diff --git a/backend/views/discount/_form.php b/backend/views/discount/_form.php new file mode 100644 index 0000000..971db92 --- /dev/null +++ b/backend/views/discount/_form.php @@ -0,0 +1,32 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/discount', "Active") ]) ?> + + field($model, 'type')->dropDownList(Discount::types()) ?> + + + field($model, 'value')->textInput() ?> + + +
+ isNewRecord ? Yii::t('common/discount', 'Create') : Yii::t('common/discount', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/discount/_search.php b/backend/views/discount/_search.php new file mode 100644 index 0000000..6a49578 --- /dev/null +++ b/backend/views/discount/_search.php @@ -0,0 +1,38 @@ + + + diff --git a/backend/views/discount/create.php b/backend/views/discount/create.php new file mode 100644 index 0000000..b8a7e00 --- /dev/null +++ b/backend/views/discount/create.php @@ -0,0 +1,21 @@ +title = Yii::t('common/discount', 'Create Discount'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/discount', 'Discounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/discount/index.php b/backend/views/discount/index.php new file mode 100644 index 0000000..1307d05 --- /dev/null +++ b/backend/views/discount/index.php @@ -0,0 +1,48 @@ +title = Yii::t('common/discount', 'Discounts'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + + +

+ 'btn btn-success']) ?> +

+ + + $dataProvider, + 'columns' => [ + 'name', + [ + 'attribute' => 'status', + 'value' => 'statusHuman', + ], + [ + 'attribute' => 'type', + 'value' => 'typeHuman', + ], + 'value', + 'created_at:datetime', + 'updated_at:datetime', + + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => RoleDefinition::getRoleTemplate( ['admin' => '{view} {update}','employee' => '{view}' , 'reception' => '{view}']), + ], + ], + ]); ?> + +
diff --git a/backend/views/discount/update.php b/backend/views/discount/update.php new file mode 100644 index 0000000..b43a463 --- /dev/null +++ b/backend/views/discount/update.php @@ -0,0 +1,23 @@ +title = Yii::t('common/discount', 'Update {modelClass}: ', [ + 'modelClass' => 'Discount', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/discount', 'Discounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_discount]]; +$this->params['breadcrumbs'][] = Yii::t('common/discount', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/discount/view.php b/backend/views/discount/view.php new file mode 100644 index 0000000..f1df9b9 --- /dev/null +++ b/backend/views/discount/view.php @@ -0,0 +1,45 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/discount', 'Discounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + +

+ $model->id_discount], ['class' => 'btn btn-primary']) ?> +

+ + + $model, + 'attributes' => [ + 'name', + [ + 'attribute' => 'status', + 'label' => Yii::t('common/discount', "Active"), + 'value' => $model->statusHuman + ], + [ + 'attribute' => 'type', + 'value' => $model->typeHuman + ], +// 'status', +// 'type', + 'value', + 'created_at', + 'updated_at', + ], + ]) ?> + +
diff --git a/backend/views/layouts/main.php b/backend/views/layouts/main.php index d5ded73..b5af7e6 100644 --- a/backend/views/layouts/main.php +++ b/backend/views/layouts/main.php @@ -9,8 +9,13 @@ use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; use common\widgets\Alert; +use backend\components\AdminMenuStructure; +use kartik\widgets\AlertBlock; AppAsset::register($this); + +$adminMenu = new AdminMenuStructure(); +$items = $adminMenu->run(); ?> beginPage() ?> @@ -28,27 +33,15 @@ AppAsset::register($this);
'My Company', + 'brandLabel' => 'Botond Fitness WebAdmin', 'brandUrl' => Yii::$app->homeUrl, 'options' => [ 'class' => 'navbar-inverse navbar-fixed-top', ], ]); - $menuItems = [ - ['label' => 'Home', 'url' => ['/site/index']], - ]; - if (Yii::$app->user->isGuest) { - $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; - } else { - $menuItems[] = [ - 'label' => 'Logout (' . Yii::$app->user->identity->username . ')', - 'url' => ['/site/logout'], - 'linkOptions' => ['data-method' => 'post'] - ]; - } echo Nav::widget([ 'options' => ['class' => 'navbar-nav navbar-right'], - 'items' => $menuItems, + 'items' => $items, ]); NavBar::end(); ?> @@ -57,14 +50,21 @@ AppAsset::register($this); isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], ]) ?> - + + true, + 'type' => AlertBlock::TYPE_GROWL, + 'delay' => '1' + ]); + ?>