Finish v.0.0.9

This commit is contained in:
Schneider Roland 2015-12-29 22:37:38 +01:00
commit d12658bfc7
478 changed files with 33676 additions and 231 deletions

6
.gitignore vendored
View File

@ -28,3 +28,9 @@ composer.phar
phpunit.phar
# local phpunit config
/phpunit.xml
/node_modules
/frontend/web/profile/**
!/frontend/web/profile/.gitkeep
/frontend/web/uploads/**

62
Gruntfile.coffee Normal file
View File

@ -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']

View File

@ -0,0 +1,124 @@
<?php
namespace backend\components;
use Yii;
use common\models\Order;
use yii\helpers\Html;
class AdminMenuStructure{
public $menuItems;
public $emptyUrl = '#';//maybe null
public function __construct(){
$this->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') );
/////////////////////////////
// Beállítások
/////////////////////////////
$items[] = ['label' => 'Felhasználók', 'url' =>['/user/index']];
$items[] = ['label' => 'Jogosultságok', 'url' =>['/user/role']];
$this->menuItems[] = ['label' => 'Beállítások', 'url' => $this->emptyUrl,
'items' => $items
];
/////////////////////////////
// Törszadatok
/////////////////////////////
$items = [];
$items[] = ['label' => 'Raktárak', 'url' =>['/warehouse/index']];
$items[] = ['label' => 'Kasszák', 'url' =>['/account/index']];
$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' => 'Kulcsok', 'url' =>['/key/index']];
// $items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
$this->menuItems[] = ['label' => 'Törszadatok', 'url' =>$this->emptyUrl,
'items' => $items
];
/////////////////////////////
// BÉRLETEK
/////////////////////////////
$items = [];
$items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] , 'target_url' => ['/customer/index' ,'/customer/view','/ticket/index-customer'] ];
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
$items[] = ['label' => 'Bérletek', 'url' => ['/ticket/index' , 'TicketSearch[start]' =>$today,'TicketSearch[end]' => $tomorrow ] ];
$this->menuItems[] = ['label' => 'Bérletek/Vendégek', 'url' => $this->emptyUrl,
'items' => $items
];
/////////////////////////////
// Termékek
/////////////////////////////
$items = [];
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
$this->menuItems[] = ['label' => 'Termékek', 'url' => $this->emptyUrl,
'items' => $items
];
/////////////////////////////
// Pénzügy
/////////////////////////////
$items = [];
$items[] = ['label' => 'Tranzakciók', 'url' => ['/transfer/index' , 'TransferSearch[start]' =>$today,'TransferSearch[end]' => $tomorrow ] ];
$items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ];
$items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
$items[] = ['label' => 'Zárások', 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$todayDatetime,'CollectionSearch[end]' => $tomorrowDatetime ] ];
$this->menuItems[] = ['label' => 'Pénzügy', 'url' => $this->emptyUrl,
'items' => $items
];
}
}
protected function addLoginMainMenu(){
if (Yii::$app->user->isGuest) {
$mainMenuItem= ['label' => Yii::t('common/site','Login'), 'url' => ['/site/login']];
} else {
$mainMenuItem= [
'label' => Yii::t('common/site','Logout') . '(' . 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;
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace backend\components;
use \Yii;
class LTEAdminMenu extends \dmstr\widgets\Menu{
/**
* Checks whether a menu item is active.
* This is done by checking if [[route]] and [[params]] match that specified in the `url` option of the menu item.
* When the `url` option of a menu item is specified in terms of an array, its first element is treated
* as the route for the item and the rest of the elements are the associated parameters.
* Only when its route and parameters match [[route]] and [[params]], respectively, will a menu item
* be considered active.
* @param array $item the menu item to be checked
* @return boolean whether the menu item is active
*/
protected function isItemActive($item)
{
if (isset($item['target_url']) && is_array($item['target_url']) ) {
foreach ($item['target_url'] as $target){
$route = $target;
if ($route[0] !== '/' && Yii::$app->controller) {
$route = Yii::$app->controller->module->getUniqueId() . '/' . $route;
}
$arrayRoute = explode('/', ltrim($route, '/'));
$arrayThisRoute = explode('/', $this->route);
if ($arrayRoute[0] !== $arrayThisRoute[0]) {
continue;
}
if (isset($arrayRoute[1]) && $arrayRoute[1] !== $arrayThisRoute[1]) {
continue;
}
if (isset($arrayRoute[2]) && $arrayRoute[2] !== $arrayThisRoute[2]) {
continue;
}
return true;
}
return false;
}else if (isset($item['url']) && is_array($item['url']) && isset($item['url'][0])) {
$route = $item['url'][0];
if ($route[0] !== '/' && Yii::$app->controller) {
$route = Yii::$app->controller->module->getUniqueId() . '/' . $route;
}
$arrayRoute = explode('/', ltrim($route, '/'));
$arrayThisRoute = explode('/', $this->route);
if ($arrayRoute[0] !== $arrayThisRoute[0]) {
return false;
}
if (isset($arrayRoute[1]) && $arrayRoute[1] !== $arrayThisRoute[1]) {
return false;
}
if (isset($arrayRoute[2]) && $arrayRoute[2] !== $arrayThisRoute[2]) {
return false;
}
// unset($item['url']['#']);
// if (count($item['url']) > 1) {
// foreach (array_splice($item['url'], 1) as $name => $value) {
// if ($value !== null && (!isset($this->params[$name]) || $this->params[$name] != $value)) {
// return false;
// }
// }
// }
return true;
}
return false;
}
}
?>

View File

@ -8,15 +8,34 @@ $params = array_merge(
return [
'id' => 'app-backend',
'name' => 'Fitness Adminisztráció',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'request' => [
'enableCsrfValidation'=>false,
// 'csrfParam' => '_backendCSRF',
// 'csrfCookie' => [
// 'path' => '/backend/web',
// ],
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_backendUser', // unique for backend
// 'path' => '/backend/web',
]
],
'session' => [
'name' => '_backendSessionId', // unique for backend
'savePath' => __DIR__ . '/../runtime', // a temporary folder on backend
'cookieParams' => [
'path' => '/backend/web',
],
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [

View File

@ -0,0 +1,124 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Account;
use backend\models\AccountSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* AccountController implements the CRUD actions for Account model.
*/
class AccountController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'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.');
}
}
}

View File

@ -0,0 +1,119 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\AccountState;
use backend\models\AccountStateSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
use common\models\User;
/**
* AccountStateController implements the CRUD actions for AccountState model.
*/
class AccountStateController extends \backend\controllers\BackendController
{
/**
* Lists all AccountState models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new AccountStateSearch();
$dataProvider = $searchModel->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.');
}
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\City;
use backend\models\CitySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\db\Query;
use yii\helpers\Json;
/**
* CityController implements the CRUD actions for City model.
*/
class BackendController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
// allow authenticated users
[
'actions' => ['create','index','view','update'],
'allow' => true,
'roles' => ['admin','employee','reception'],
],
// everything else is denied
],
],
];
}
}

View File

@ -0,0 +1,171 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Card;
use backend\models\CardSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\db\Query;
use common\models\Customer;
use yii\helpers\Json;
/**
* CardController implements the CRUD actions for Card model.
*/
class CardController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'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 );
}
}

View File

@ -0,0 +1,179 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\City;
use backend\models\CitySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\db\Query;
use yii\helpers\Json;
/**
* CityController implements the CRUD actions for City model.
*/
class CityController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'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 );
}
}

View File

@ -0,0 +1,97 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Collection;
use backend\models\CollectionSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
use common\models\Transfer;
use common\models\User;
/**
* CollectionController implements the CRUD actions for Collection model.
*/
class CollectionController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'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.');
}
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Currency;
use backend\models\CurrencySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* CurrencyController implements the CRUD actions for Currency model.
*/
class CurrencyController extends \backend\controllers\BackendController
{
/**
* Lists all Currency models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CurrencySearch();
$dataProvider = $searchModel->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.');
}
}
}

View File

@ -0,0 +1,122 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Customer;
use backend\models\CustomerSearch;
use backend\models\CustomerCreate;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use backend\models\CustomerUpdate;
/**
* CustomerController implements the CRUD actions for Customer model.
*/
class CustomerController extends \backend\controllers\BackendController
{
/**
* Lists all Customer models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CustomerSearch();
$dataProvider = $searchModel->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.');
}
}
}

View File

@ -0,0 +1,124 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Discount;
use backend\models\DiscountSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* DiscountController implements the CRUD actions for Discount model.
*/
class DiscountController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'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.');
}
}
}

View File

@ -0,0 +1,122 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Key;
use backend\models\KeySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* KeyController implements the CRUD actions for Key model.
*/
class KeyController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Key models.
* @return mixed
*/
//http://localhost/fitness-web/backend/web/index.php?r=key/index erre ezt hívja meg elsőzör
public function actionIndex()
{
$searchModel = new KeySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
// backend/views/kex/index.php
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider, //csomagoló osztály a queryhez
]);
}
/**
* Displays a single Key model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Key model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Key();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_key]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Key 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_key]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Key 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 Key model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Key the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Key::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,232 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Procurement;
use backend\models\ProcurementSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Warehouse;
use common\models\Product;
use common\models\User;
use common\components\Helper;
/**
* ProcurementController implements the CRUD actions for Procurement model.
*/
class ProcurementController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'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.');
}
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\ProductCategory;
use backend\models\ProductCategorySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ProductCategoryController implements the CRUD actions for ProductCategory model.
*/
class ProductCategoryController extends \backend\controllers\BackendController
{
/**
* Lists all ProductCategory models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ProductCategorySearch();
$dataProvider = $searchModel->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.');
}
}
}

View File

@ -0,0 +1,125 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Product;
use backend\models\ProductSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
use common\models\ProductCategory;
/**
* ProductController implements the CRUD actions for Product model.
*/
class ProductController extends \backend\controllers\BackendController
{
/**
* Lists all Product models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ProductSearch();
$dataProvider = $searchModel->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.');
}
}
}

View File

@ -6,6 +6,7 @@ use yii\filters\AccessControl;
use yii\web\Controller;
use common\models\LoginForm;
use yii\filters\VerbFilter;
use backend\models\UploadForm;
/**
* Site controller
@ -22,7 +23,7 @@ class SiteController extends Controller
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error'],
'actions' => ['login', 'error','upload-image'],
'allow' => true,
],
[
@ -65,6 +66,10 @@ class SiteController extends Controller
}
$model = new LoginForm();
$model->roles = [
'admin',
'employee'
];
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
@ -80,4 +85,11 @@ class SiteController extends Controller
return $this->goHome();
}
public function actionUploadImage(){
\yii::$app->request->enableCsrfValidation = false;
$model = new UploadForm();
return $this->render('upload', ['model' =>$model]);
}
}

View File

@ -0,0 +1,186 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Ticket;
use backend\models\TicketSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Discount;
use common\models\TicketType;
use common\models\Account;
use common\models\User;
use common\models\Customer;
use common\models\Card;
/**
* TicketController implements the CRUD actions for Ticket model.
*/
class TicketController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
// allow authenticated users
[
'actions' => ['create','index','view','update','index-customer'],
'allow' => true,
'roles' => ['admin','employee','reception'],
],
// everything else is denied
],
],
];
}
/**
* Lists all Ticket models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TicketSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$searchModel->searchTotals();
$searchModel->users = User::read();
$searchModel->accounts = Account::read();
$searchModel->ticketTypes = TicketType::read();
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Lists all Ticket models.
* @return mixed
*/
public function actionIndexCustomer($id)
{
$customer = Customer::findOne($id);
$card = Card::findOne($id);
if ( $customer == null ){
throw new NotFoundHttpException('The requested page does not exist.');
}
$searchModel = new TicketSearch();
$searchModel->id_card = $customer->id_customer_card;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$searchModel->searchTotals();
$searchModel->users = User::read();
$searchModel->accounts = Account::read();
$searchModel->ticketTypes = TicketType::read();
return $this->render('index_customer', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'customer' => $customer,
'card' => $card
]);
}
/**
* 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.');
}
}
}

View File

@ -0,0 +1,133 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\TicketType;
use backend\models\TicketTypeSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
/**
* TicketTypeController implements the CRUD actions for TicketType model.
*/
class TicketTypeController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'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.');
}
}
}

View File

@ -0,0 +1,132 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Transfer;
use backend\models\TransferSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
use common\models\User;
use backend\models\TransferSummarySearch;
/**
* TransferController implements the CRUD actions for Transfer model.
*/
class TransferController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
// allow authenticated users
[
'actions' => [ 'index','view','summary' ],
'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,
]);
}
/**
* Lists all Transfer models.
* @return mixed
*/
public function actionSummary()
{
$searchModel = new TransferSummarySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$accounts = Account::read();
$users = User::read();
return $this->render('summary', [
'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.');
}
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace backend\controllers;
use yii\rest\Controller;
use common\models\Image;
use backend\models\UploadForm;
use yii\web\UploadedFile;
USE Yii;
class UploadController extends Controller
{
// public function verbs()
// {
// $verbs = [];
// $verbs[ "upload" ] = ['POST' ];
// return $verbs;
// }
public function actionUpload()
{
$model = new UploadForm();
$resp = [];
if ( $model->load(Yii::$app->request->post()) && $model->validate()) {
$model->image = UploadedFile::getInstance($model, 'image');
/**save into frontend/web/uploads/profile*/
$path = \common\components\Image::upload($model->image,'profile');
$image = new Image();
$image->path = $path;
$image->save();
/* the result object that is sent to client*/
$resp['ok'] = 1;
$resp['id_image'] = $image->id_image;
}else{
$resp['ok'] = 0;
$resp['message'] = print_r($model->errors,true);
}
return $resp;
}
}

View File

@ -0,0 +1,233 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\User;
use backend\models\UserSearch;
use backend\models\UserCreate;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use backend\models\UserUpdate;
use common\models\Account;
use common\models\UserAccountAssignment;
use common\components\RoleDefinition;
/**
* UserController implements the CRUD actions for User model.
*/
class UserController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
// allow authenticated users
[
'actions' => [ 'index','view' ,'role'],
'allow' => true,
'roles' => ['employee','admin' ],
],
// 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']);
}
/**
* Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionRole()
{
$model = new \backend\models\RoleForm();
$model->availablePermissions = [
[
'name' => "reception.transfers",
'description' => 'Tranzakciók'
]
];
if ($model->load(Yii::$app->request->post()) ) {
if ( $model->validate() && $model->save()){
Yii::$app->session->setFlash('success', 'Jogosultságok elmentve');
return $this->redirect(['role' ]);
}
}else{
$am = Yii::$app->authManager;
$children = $am->getChildren(User::ROLE_RECEPTION);
$model->permissions = [];
foreach ($children as $child){
$model->permissions[] = $child->name;
}
}
return $this->render('role', [
'model' => $model,
]);
}
/**
* Finds the User model based on its primary key value.
* 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.');
}
}
}

View File

@ -0,0 +1,114 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Warehouse;
use backend\models\WarehouseSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
/**
* WarehouseController implements the CRUD actions for Warehouse model.
*/
class WarehouseController extends \backend\controllers\BackendController
{
/**
* Lists all Warehouse models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new WarehouseSearch();
$dataProvider = $searchModel->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.');
}
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Account;
use common\components\RoleDefinition;
/**
* AccountSearch represents the model behind the search form about `common\models\Account`.
*/
class AccountSearch extends Account
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_account', 'status', 'type'], 'integer'],
[['name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @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 = Account::find();
if ( !RoleDefinition::isAdmin() ){
$query->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;
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\AccountState;
use common\components\RoleDefinition;
/**
* AccountStateSearch represents the model behind the search form about `common\models\AccountState`.
*/
class AccountStateSearch extends AccountState
{
public $type;
public $start;
public $end;
public $timestampStart;
public $timestampEnd;
/**
* @inheritdoc
*/
public function rules()
{
return [
[[ 'id_account', 'type', 'id_user'], 'integer'],
[[ 'start', ], 'date' , 'timestampAttribute' => '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;
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Card;
use common\models\Customer;
/**
* CardSearch represents the model behind the search form about `common\models\Card`.
*/
class CardSearch extends Card
{
public $searchCustomerName;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_card', 'status', 'type'], 'integer'],
[[ 'searchCustomerName', 'number','rfid_key', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @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 = Card::find();
$dataProvider = new ActiveDataProvider([
'query' => $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', 'card.rfid_key', $this->rfid_key]);
$query->andFilterWhere(['like', 'customer.name', $this->searchCustomerName]);
return $dataProvider;
}
public function attributeLabels(){
$result = parent::attributeLabels();
$result +=[
'searchCustomerName' => Yii::t('common/card','Customer')
];
return $result;
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\City;
/**
* CitySearch represents the model behind the search form about `common\models\City`.
*/
class CitySearch extends City
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_city', 'cso_code', 'rig_id', 'population', 'homes'], 'integer'],
[['zip', 'name', 'city_code'], 'safe'],
[['latitude', 'longitude', 'range'], 'number'],
];
}
/**
* @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 = City::find();
$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_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;
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Collection;
use common\components\Helper;
use common\components\RoleDefinition;
/**
* CollectionSearch represents the model behind the search form about `common\models\Collection`.
*/
class CollectionSearch extends Collection
{
public $accounts;
public $accountMap;
public $users;
public $timestampStart;
public $timestampEnd;
public $totals;
/**
* @inheritdoc
*/
public function rules()
{
return [
[[ 'start', ], 'date', 'format' =>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);
}
}

View File

@ -0,0 +1,70 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Currency;
/**
* CurrencySearch represents the model behind the search form about `common\models\Currency`.
*/
class CurrencySearch extends Currency
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_currency', 'rate'], 'integer'],
[['currency', 'name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @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 = Currency::find();
$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_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;
}
}

View File

@ -0,0 +1,135 @@
<?php
namespace backend\models;
use Yii;
use common\models\Customer;
use common\models\Card;
/**
* This is the model class for table "customer".
*
* @property integer $id_customer
* @property integer $id_customer_card
* @property integer $id_user
* @property integer $id_partner_card
* @property integer $id_proposer
* @property string $name
* @property string $email
* @property string $password
* @property string $phone
* @property integer $sex
* @property string $date_stundent_card_expire
* @property string $birthdate
* @property string $image
* @property string $description
* @property string $tax_number
* @property string $country
* @property string $zip
* @property string $city
* @property string $address
* @property string $created_at
* @property string $updated_at
* @property string $cardNumber
*/
class CustomerCreate extends \common\models\Customer
{
public $cardNumber;
public $partnerCardNumber;
public $password_plain;
public $password_repeat;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'customer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cardNumber'], 'required' ],
[['cardNumber'], 'string', 'max' => 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;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Customer;
use common\models\Card;
/**
* CustomerSearch represents the model behind the search form about `common\models\Customer`.
*/
class CustomerSearch extends Customer
{
public $cardNumber;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cardNumber', 'name', 'email'] ,'safe']
// [['id_customer', 'id_customer_card', 'id_user', 'id_partner_card', 'id_proposer', 'sex'], 'integer'],
// [['name', 'email', 'password', 'phone', 'date_stundent_card_expire', 'birthdate', 'image', 'description', 'tax_number', 'country', 'zip', 'city', 'address', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @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 = Customer::find();
$dataProvider = new ActiveDataProvider([
'query' => $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;
}
}

View File

@ -0,0 +1,115 @@
<?php
namespace backend\models;
use Yii;
use common\models\Customer;
/**
* This is the model class for table "customer".
*
* @property integer $id_customer
* @property integer $id_customer_card
* @property integer $id_user
* @property integer $id_partner_card
* @property integer $id_proposer
* @property string $name
* @property string $email
* @property string $password
* @property string $phone
* @property integer $sex
* @property string $date_stundent_card_expire
* @property string $birthdate
* @property string $image
* @property string $description
* @property string $tax_number
* @property string $country
* @property string $zip
* @property string $city
* @property string $address
* @property string $created_at
* @property string $updated_at
* @property string $cardNumber
*/
class CustomerUpdate extends \common\models\Customer
{
public $cardNumber;
public $partnerCardNumber;
public $password_plain;
public $password_repeat;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'customer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
// [['cardNumber'], 'required' ],
// [['cardNumber'], 'string', 'max' => 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 )
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Discount;
/**
* DiscountSearch represents the model behind the search form about `common\models\Discount`.
*/
class DiscountSearch extends Discount
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_discount', 'status', 'type', 'value'], 'integer'],
[['name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @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 = Discount::find();
$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_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;
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Key;
/**
* KeySearch represents the model behind the search form about `common\models\Key`.
*/
class KeySearch extends Key
{
/**
* @inheritdoc
*/
public function rules()
{
return [
/*[['id_key', 'status', 'type'], 'integer'],
[['number', 'created_at', 'updated_at'], 'safe'],*/
[['number'], 'safe'],
[['rfid_key'], 'safe']
];
}
/**
* @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 = Key::find();
$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_key' => $this->id_key,
'number' => $this->number,
'rfid_key' => $this->rfid_key,
'status' => $this->status,
'type' => $this->type,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'number', $this->number]);
return $dataProvider;
}
}

View File

@ -0,0 +1,91 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Procurement;
use common\components\RoleDefinition;
/**
* ProcurementSearch represents the model behind the search form about `common\models\Procurement`.
*/
class ProcurementSearch extends Procurement
{
public $date_start;
public $date_end;
public $timestampStart;
public $timestampEnd;
/**
* @inheritdoc
*/
public function rules()
{
return [
[[ 'id_warehouse', 'id_user', 'id_product', ], 'integer'],
[[ 'date_start', ], 'date' , 'timestampAttribute' => '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;
}
}

View File

@ -0,0 +1,69 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\ProductCategory;
/**
* ProductCategorySearch represents the model behind the search form about `common\models\ProductCategory`.
*/
class ProductCategorySearch extends ProductCategory
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_product_category', 'status'], 'integer'],
[['name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @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 = ProductCategory::find();
$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_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;
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Product;
use common\components\RoleDefinition;
/**
* ProductSearch represents the model behind the search form about `common\models\Product`.
*/
class ProductSearch extends Product
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[[ 'id_product_category', 'id_account', 'status'], 'integer'],
[['product_number', 'barcode' ,'name'], 'safe'],
];
}
/**
* @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 = Product::find();
if ( !RoleDefinition::isAdmin() ){
$query->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])
->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace backend\models;
use yii\base\Model;
use common\models\User;
class RoleForm extends Model{
public $permissions =[];
public $availablePermissions = [];
/**
* @inheritdoc
* @formatter:off
*/
public function rules()
{
return [
['permissions',function ($attribute, $params) {
if (!is_array($this->$attribute)) {
echo "invalid arr";
$this->addError($attribute, 'Invalid array');
}
}
],
];
}
public function save(){
$am = \Yii::$app->authManager;
//remove all reception permission
$receptionItem = $am->getRole(User::ROLE_RECEPTION);
$am->removeChildren($receptionItem);
if ( isset($receptionItem)){
foreach ($this->permissions as $permissionName){
$permission = $am->getPermission($permissionName);
if ( isset( $permission )){
$am->addChild($receptionItem, $permission);
}
}
}
return true;
}
}

View File

@ -0,0 +1,223 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Ticket;
use common\components\Helper;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;
/**
* TicketSearch represents the model behind the search form about `common\models\Ticket`.
*/
class TicketSearch extends Ticket
{
public $timestampStart;
public $timestampEnd;
public $users;
public $accounts;
public $ticketTypes;
public $valid_in_interval;
public $created_in_interval;
public $expire_in_interval;
public $statistics;
public $statisticsTotal;
/**
* @inheritdoc
*/
public function rules()
{
return [
[[ 'id_user', 'id_ticket_type', 'id_account'], 'integer'],
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] ,
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
public function attributeLabels(){
return ArrayHelper::merge(parent::attributeLabels(), [
'start' => Yii::t('backend/ticket','Start of interval'),
'end' => Yii::t('backend/ticket','End of interval'),
'valid_in_interval' => Yii::t('backend/ticket','Valid in interval'),
'created_in_interval' => Yii::t('backend/ticket','Created in interval'),
'expire_in_interval' => Yii::t('backend/ticket','Expire in interval'),
]);
}
public function afterValidate(){
if ( !isset($this->timestampStart)) {
$this->timestampStart ='1900-01-01';
}
if ( !isset($this->timestampEnd)) {
$this->timestampEnd ='3000-01-01';
}
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Ticket::find();
Helper::queryAccountConstraint($query, 'ticket.id_account');
$query->with('ticketType' );
$query->with('user');
$query->with('customer');
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' =>[
'defaultOrder' => ['end' => SORT_DESC],
'attributes' => ['end']
]
]);
$this->load($params);
if (!$this->validate()) {
$query->where('0=1');
return $query;
}
$query->andFilterWhere([
'id_user' => $this->id_user,
'id_ticket_type' => $this->id_ticket_type,
'id_account' => $this->id_account,
'id_card' => $this->id_card,
]);
$all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) )
||
($this->valid_in_interval == true && $this->expire_in_interval == true && $this->created_in_interval);
$dateConditions = [];
$start = $this->timestampStart;
$end = $this->timestampEnd;
if( $all || $this->created_in_interval ){
$dateConditions[] = Helper::queryInIntervalRule('ticket.created_at', $start, $end);
}
if ( $all || $this->valid_in_interval ){
$dateConditions[] = Helper::queryValidRule('ticket.start', 'ticket.end', $start, $end);
}
if ( $all || $this->expire_in_interval ){
$dateConditions[] = Helper::queryExpireRule('ticket.start', 'ticket.end', $start, $end);
}
if ( count($dateConditions) == 1 ){
$query->andWhere($dateConditions[0]);
}else if ( count($dateConditions) > 1 ){
$cond = ['or'];
foreach ($dateConditions as $c){
$cond[] = $c;
}
$query->andWhere($cond);
}
return $dataProvider;
}
public function searchTotals(){
$query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd,$this->id_card);
$this->statistics = $query->all();
$this->statisticsTotal =[
'valid' => 0,
'created' => 0,
'created_at_money' => 0,
'expired' => 0,
];
$this->statisticsTotal['valid'] = array_sum(array_column($this->statistics, 'valid'));
$this->statisticsTotal['created'] = array_sum(array_column($this->statistics, 'created'));
$this->statisticsTotal['created_money'] = array_sum(array_column($this->statistics, 'created_money'));
$this->statisticsTotal['expired'] = array_sum(array_column($this->statistics, 'expired'));
}
public static function mkSearchCondition( $timestampStart, $timestampEnd, $id_user,$id_ticket_tpye,$id_account,$valid_in_interval ,$expire_in_interval,$created_in_interval ){
$query = Ticket::find();
Helper::queryAccountConstraint($query, 'ticket.id_account');
$query->with('ticketType' );
$query->with('user');
$query->with('customer');
$query->andFilterWhere([
'id_user' => $id_user,
'id_ticket_type' => $id_ticket_type,
'id_account' => $id_account,
]);
$all = (!($valid_in_interval) && !($expire_in_interval) && !($created_in_interval) )
||
($valid_in_interval == true && $expire_in_interval == true && $created_in_interval);
$dateConditions = [];
$start = $timestampStart;
$end = $timestampEnd;
if( $all || $created_in_interval ){
$dateConditions[] = Helper::queryInIntervalRule('ticket.created_at', $start, $end);
}
if ( $all || $valid_in_interval ){
$dateConditions[] = Helper::queryValidRule('ticket.start', 'ticket.end', $start, $end);
}
if ( $all || $expire_in_interval ){
$dateConditions[] = Helper::queryExpireRule('ticket.start', 'ticket.end', $start, $end);
}
if ( count($dateConditions) == 1 ){
$query->andWhere($dateConditions[0]);
}else if ( count($dateConditions) > 1 ){
$cond = ['or'];
foreach ($dateConditions as $c){
$cond[] = $c;
}
$query->andWhere($cond);
}
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\TicketType;
/**
* TicketTypeSearch represents the model behind the search form about `common\models\TicketType`.
*/
class TicketTypeSearch extends TicketType
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_ticket_type', 'type', 'max_usage_count', 'time_unit_type', 'time_unit_count', 'price_brutto', 'id_account', 'flag_student', 'status'], 'integer'],
[['name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @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 = TicketType::find();
$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_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;
}
}

View File

@ -0,0 +1,128 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Transfer;
use yii\db\Expression;
use yii\base\Object;
use yii\db\Query;
use yii\helpers\ArrayHelper;
use common\models\Account;
use common\components\Helper;
use common\components\RoleDefinition;
/**
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
*/
class TransferSearch extends Transfer
{
public $searchObjectName;
public $searchTypeName;
public $searchUserName;
public $start;
public $end;
public $timestampStart;
public $timestampEnd;
public $accountTotals;
public $fullTotal;
public $types;
public $totals;
/**
* @inheritdoc
*/
public function rules()
{
return [
[[ 'id_account','id_user', 'type'], 'integer'],
// [[ 'searchObjectName' ], 'string'],
[[ 'start', ], 'date' , 'timestampAttribute' => '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 = $this->id_user;
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
}
}

View File

@ -0,0 +1,180 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Transfer;
use yii\db\Expression;
use yii\base\Object;
use yii\db\Query;
use yii\helpers\ArrayHelper;
use common\models\Account;
use common\components\Helper;
use common\components\RoleDefinition;
/**
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
*/
class TransferSummarySearch extends Transfer
{
public $searchObjectName;
public $searchTypeName;
public $searchUserName;
public $start;
public $end;
public $timestampStart;
public $timestampEnd;
public $types;
/**
* all money gained with ticket sell
* */
public $ticketMoney;
/**
* all money gained with product sell grouped by category
* */
public $productMoneies;
/**
* all money lost by money movement
* */
public $moneyMovementMoneis;
/**
* total gained money
* */
public $total;
/**
* @inheritdoc
*/
public function rules()
{
return [
[[ 'id_account','id_user', 'type'], 'integer'],
// [[ 'searchObjectName' ], 'string'],
[[ 'start', ], 'date' , 'timestampAttribute' => '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)
{
$this->load($params);
if (!$this->validate()) {
// $query->where('0=1');
// return $dataProvider;
}
$this->readTicketMoney();
$this->readProductsByCategory();
$this->readMoneyMovements();
$this->calcTotal();
}
protected function calcTotal(){
$this->total = 0;
$this->total += $this->ticketMoney;
$this->total -= $this->moneyMovementMoneis['money_movement_money'];
foreach ($this->productMoneies as $pm ){
$this->total += $pm['product_money'];
}
}
protected function addQueryFilters($query){
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 ]);
}
$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]);
$query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
}
protected function readTicketMoney(){
$query = (new \yii\db\Query());
$query->select([' coalesce(sum(abs(transfer.money)),0) AS ticket_money']);
$query->from('transfer');
$query->andWhere(['transfer.type' => Transfer::TYPE_TICKET]);
$query->innerJoin("ticket", "ticket.id_ticket = transfer.id_object");
$this->addQueryFilters($query);
// $query = Transfer::find();
// $query->andWhere(['type' => Transfer::TYPE_TICKET]);
// $this->addQueryFilters($query);
$this->ticketMoney = $query->scalar();
print_r($this->ticketMoney);
}
protected function readProductsByCategory(){
$query = (new \yii\db\Query());
$query->select(['coalesce(sum(transfer.money),0) AS product_money', 'product_category.name as category_name']);
$query->from('transfer');
$query->groupBy(['product_category.id_product_category','product_category.name']);
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
$query->innerJoin("sale", "sale.id_sale = transfer.id_object");
$query->innerJoin("product", "sale.id_product = product.id_product");
$query->innerJoin("product_category", "product.id_product_category = product_category.id_product_category");
$this->addQueryFilters($query);
$this->productMoneies = $query->all();
}
protected function readMoneyMovements(){
$query = (new \yii\db\Query());
$query->select([' coalesce(sum(abs(transfer.money)),0) AS money_movement_money']);
$query->from('transfer');
$query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]);
$query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object");
$this->addQueryFilters($query);
$this->moneyMovementMoneis = $query->one();
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace backend\models;
use yii\base\Model;
use common\models\User;
use common\models\Image;
class UploadForm extends Model{
const SECRET= "aN6obLS2wMFzXw2VQBar";
public $image ;
public $secret;
/**
* @inheritdoc
* @formatter:off
*/
public function rules()
{
return [
[['image'], 'image', 'mimeTypes' => 'image/jpeg, image/png', 'extensions'=>'jpg, png'],
[['image'], 'required',],
[['secret'], 'required'],
[['secret'], 'validSecret'],
];
}
public function validSecret(){
if ( $this->secret != self::SECRET ){
$this->addError("secret","Invalid secret");
}
}
public function save(){
$image = new Image();
return true;
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace backend\models;
use Yii;
use common\models\User;
class UserCreate extends User{
public $password_plain;
public $password_repeat;
public $selected_accounts = [];
public $role;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['username','email','password_plain','password_repeat'], 'required' ],
['selected_accounts',function ($attribute, $params) {
if (!is_array($this->$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);
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\User;
/**
* UserSearch represents the model behind the search form about `common\models\User`.
*/
class UserSearch extends User
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'status', 'created_at', 'updated_at'], 'integer'],
[['username', 'auth_key', 'password_hash', 'password_reset_token', 'email'], 'safe'],
];
}
/**
* @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 = User::find();
$dataProvider = new ActiveDataProvider([
'query' => $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;
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace backend\models;
use Yii;
use common\models\User;
class UserUpdate extends User {
public $password_plain;
public $password_repeat;
public $selected_accounts = [];
public $role;
/**
* @inheritdoc
* @formatter:off
*/
public function rules()
{
return [
[['username','email'], 'required' ],
['email' ,'email' ],
['email' ,'unique' , 'targetClass' => 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);
}
}

View File

@ -0,0 +1,69 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Warehouse as WarehouseModel;
/**
* Warehouse represents the model behind the search form about `common\models\Warehouse`.
*/
class WarehouseSearch extends WarehouseModel
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_warehouse', 'status', 'created_at', 'updated_at'], 'integer'],
[['name'], 'safe'],
];
}
/**
* @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 = WarehouseModel::find();
$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_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;
}
}

View File

@ -0,0 +1,55 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\AccountState */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="account-state-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_account')->textInput() ?>
<?= $form->field($model, 'type')->textInput() ?>
<?= $form->field($model, 'money')->textInput() ?>
<?= $form->field($model, 'banknote_5_ft')->textInput() ?>
<?= $form->field($model, 'banknote_10_ft')->textInput() ?>
<?= $form->field($model, 'banknote_20_ft')->textInput() ?>
<?= $form->field($model, 'banknote_50_ft')->textInput() ?>
<?= $form->field($model, 'banknote_100_ft')->textInput() ?>
<?= $form->field($model, 'banknote_200_ft')->textInput() ?>
<?= $form->field($model, 'banknote_500_ft')->textInput() ?>
<?= $form->field($model, 'banknote_1000_ft')->textInput() ?>
<?= $form->field($model, 'banknote_2000_ft')->textInput() ?>
<?= $form->field($model, 'banknote_5000_ft')->textInput() ?>
<?= $form->field($model, 'banknote_10000_ft')->textInput() ?>
<?= $form->field($model, 'banknote_20000_ft')->textInput() ?>
<?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'prev_state')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend/account-state', 'Create') : Yii::t('backend/account-state', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,13 @@
<?php
use frontend\components\AccountStateBanknoteCountWidget;
use yii\base\Widget;
?>
<?php
echo AccountStateBanknoteCountWidget::widget([
'model' => $model,
]);
?>

View File

@ -0,0 +1,68 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\AccountState;
use frontend\components\HtmlHelper;
use kartik\widgets\DatePicker;
/* @var $this yii\web\View */
/* @var $model backend\models\AccountStateSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
$accountOptions = ['' => 'Mind'] + HtmlHelper::mkAccountOptions($accounts);
$userOptions = ['' => 'Mind'] + HtmlHelper::mkOptions($users,'id','username')
?>
<div class="account-state-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class='row'>
<div class='col-md-4'>
<?= $form->field($model, 'id_user')->dropDownList($userOptions) ?>
</div>
<div class='col-md-4'>
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
</div>
<div class='col-md-4'>
<?= $form->field($model, 'type')->dropDownList(['' => 'Mind']+AccountState::types()) ?>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
<div class="col-md-4">
<?= $form->field($model, 'end') ->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('backend/account-state', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\AccountState */
$this->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;
?>
<div class="account-state-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\ListView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\AccountStateSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend/account-state', 'Account States');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-state-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel,'accounts' => $accounts,'users' => $users,]); ?>
<?php /*echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'typeName',
'money',
'created_at:datetime',
['class' => 'yii\grid\ActionColumn',
'template' => '{view}'
],
],
]); */?>
<?php echo ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_item_view'
])?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\AccountState */
$this->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');
?>
<div class="account-state-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,56 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\AccountState */
$this->title = $model->id_account_state;
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/account-state', 'Account States'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-state-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('backend/account-state', 'Update'), ['update', 'id' => $model->id_account_state], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('backend/account-state', 'Delete'), ['delete', 'id' => $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',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $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',
],
]) ?>
</div>

View File

@ -0,0 +1,29 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Account;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="account-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/account', "Active") ]) ?>
<?= $form->field($model, 'type')->dropDownList(Account::types()) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/account', 'Create') : Yii::t('common/account', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\AccountSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="account-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_account') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'status') ?>
<?= $form->field($model, 'type') ?>
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/account', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('common/account', 'Reset'), ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
$this->title = Yii::t('common/account', 'Create Account');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/account', 'Accounts'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use common\components\RoleDefinition;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\AccountSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/account', 'Accounts');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<?php if ( RoleDefinition::isAdmin()) {?>
<p>
<?= Html::a(Yii::t('common/account', 'Create Account'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?php }?>
<?= GridView::widget([
'dataProvider' => $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}']),
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
$this->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');
?>
<div class="account-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,42 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\components\RoleDefinition;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/account', 'Accounts'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-view">
<h1><?= Html::encode($this->title) ?></h1>
<?php if ( RoleDefinition::isAdmin() ){?>
<p>
<?= Html::a(Yii::t('common/account', 'Update'), ['update', 'id' => $model->id_account], ['class' => 'btn btn-primary']) ?>
</p>
<?php }?>
<?= DetailView::widget([
'model' => $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',
],
]) ?>
</div>

View File

@ -0,0 +1,31 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Card;
/* @var $this yii\web\View */
/* @var $model common\models\Card */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="card-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'number')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'rfid_key')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->dropDownList(Card::statuses()) ?>
<?= $form->field($model, 'type')->dropDownList(Card::types()) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/card', 'Create') : Yii::t('common/card', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
<?= Html::submitButton( Yii::t('common/card', 'Create/Next') ,['class' => 'btn btn-primary','name'=>'create_next']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,63 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Card;
/* @var $this yii\web\View */
/* @var $model backend\models\CardSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
function mkOptions($options){
$all = ['' => Yii::t('common/product','All' ) ];
$o = $all + $options;
return $o;
}
$typeOptions = mkOptions(Card::types());
$statusOptions = mkOptions(Card::statuses());
?>
<div class="card-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'number') ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'status')->dropDownList($statusOptions) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'type')->dropDownList($typeOptions) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'searchCustomerName')->textInput() ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'rfid_key')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/card', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Card */
$this->title = Yii::t('common/card', 'Create Card');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="card-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,56 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CardSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/card', 'Cards');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="card-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/card', 'Create Card'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'number',
'value' => 'number'
],
[
'attribute' => 'rfid_key',
'value' => 'rfid_key'
],
[
'attribute' => 'status',
'value' => 'statusHuman'
],
[
'attribute' => 'type',
'value' => 'typeHuman'
],
[
'attribute' => 'customerName',
'value' => 'customerName'
],
'updated_at:datetime',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view}{update}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Card */
$this->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');
?>
<div class="card-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Card */
$this->title = Yii::t('common/card','Card: ').$model->number;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="card-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/card', 'Update'), ['update', 'id' => $model->id_card], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'number',
'rfid_key',
['attribute' => 'status', 'value' => $model->statusHuman],
['attribute' => 'type', 'value' => $model->typeHuman],
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

View File

@ -0,0 +1,41 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\City */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="city-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'zip')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'city_code')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'latitude')->textInput() ?>
<?= $form->field($model, 'longitude')->textInput() ?>
<?= $form->field($model, 'cso_code')->textInput() ?>
<?= $form->field($model, 'rig_id')->textInput() ?>
<?= $form->field($model, 'range')->textInput() ?>
<?= $form->field($model, 'population')->textInput() ?>
<?= $form->field($model, 'homes')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/city', 'Create') : Yii::t('common/city', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\CitySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="city-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_city') ?>
<?= $form->field($model, 'zip') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'city_code') ?>
<?= $form->field($model, 'latitude') ?>
<?php // echo $form->field($model, 'longitude') ?>
<?php // echo $form->field($model, 'cso_code') ?>
<?php // echo $form->field($model, 'rig_id') ?>
<?php // echo $form->field($model, 'range') ?>
<?php // echo $form->field($model, 'population') ?>
<?php // echo $form->field($model, 'homes') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/city', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('common/city', 'Reset'), ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\City */
$this->title = Yii::t('common/city', 'Create City');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/city', 'Cities'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="city-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,44 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/city', 'Cities');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="city-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/city', 'Create City'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $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'],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\City */
$this->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');
?>
<div class="city-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,45 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\City */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/city', 'Cities'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="city-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/city', 'Update'), ['update', 'id' => $model->id_city], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('common/city', 'Delete'), ['delete', 'id' => $model->id_city], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('common/city', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_city',
'zip',
'name',
'city_code',
'latitude',
'longitude',
'cso_code',
'rig_id',
'range',
'population',
'homes',
],
]) ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Collection */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="collection-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_user')->textInput() ?>
<?= $form->field($model, 'created_by')->textInput() ?>
<?= $form->field($model, 'id_account')->textInput() ?>
<?= $form->field($model, 'money')->textInput() ?>
<?= $form->field($model, 'start')->textInput() ?>
<?= $form->field($model, 'end')->textInput() ?>
<?= $form->field($model, 'type')->textInput() ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<?= $form->field($model, 'updated_at')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend/collection', 'Create') : Yii::t('backend/collection', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,61 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use frontend\components\HtmlHelper;
use kartik\widgets\DateTimePicker;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model backend\models\CollectionSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
$accountOptions = ['' =>Yii::t('frontend/collection','All')]+ HtmlHelper::mkAccountOptions($model->accounts);
$userOptions = ['' =>Yii::t('frontend/collection','All')]+ ArrayHelper::map($model->users,'id','username');
?>
<div class="collection-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'id_account')->dropDownList( $accountOptions ) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'id_user')->dropDownList( $userOptions ) ?>
</div>
<div class="col-md-3">
<?= $form->field($model, 'start')->widget(DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd hh:ii'
]
]) ?>
</div>
<div class="col-md-3">
<?= $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd hh:ii'
]
]) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('frontend/collection', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Collection */
$this->title = Yii::t('backend/collection', 'Create Collection');
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/collection', 'Collections'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="collection-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,63 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use common\components\AccountTotalWidget;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CollectionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend/collection', 'Collections');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="collection-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<div class="row">
<div class="col-md-4 ">
<?php
echo AccountTotalWidget::widget([
'statistic' => $searchModel->totals
])?>
</div>
</div>
<?= GridView::widget([
'dataProvider' => $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}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Collection */
$this->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');
?>
<div class="collection-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,44 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\components\AccountStatisticWidget;
/* @var $this yii\web\View */
/* @var $model common\models\Collection */
$this->title = $model->id_collection;
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/collection', 'Collections'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="collection-view">
<h1><?= Html::encode($this->title) ?></h1>
<?= DetailView::widget([
'model' => $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',
],
]) ?>
<?php
echo AccountStatisticWidget::widget([
'totals' => $totals
]);
?>
</div>

View File

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Currency */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="currency-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'currency')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'rate')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('frontend/currency', 'Create') : Yii::t('frontend/currency', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\CurrencySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="currency-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_currency') ?>
<?= $form->field($model, 'currency') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'rate') ?>
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('frontend/currency', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('frontend/currency', 'Reset'), ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Currency */
$this->title = Yii::t('frontend/currency', 'Create Currency');
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="currency-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CurrencySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('frontend/currency', 'Currencies');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="currency-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('frontend/currency', 'Create Currency'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'currency',
'name',
'rate',
// 'created_at:datetime',
'updated_at:datetime:datetime',
['class' => 'yii\grid\ActionColumn',
'template' =>'{view} {update}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Currency */
$this->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');
?>
<div class="currency-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,32 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Currency */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="currency-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('frontend/currency', 'Update'), ['update', 'id' => $model->id_currency], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'currency',
'name',
'rate',
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

View File

@ -0,0 +1,61 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="customer-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_customer_card')->textInput() ?>
<?= $form->field($model, 'id_user')->textInput() ?>
<?= $form->field($model, 'id_partner_card')->textInput() ?>
<?= $form->field($model, 'id_proposer')->textInput() ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sex')->textInput() ?>
<?= $form->field($model, 'date_stundent_card_expire')->textInput() ?>
<?= $form->field($model, 'birthdate')->textInput() ?>
<?= $form->field($model, 'image')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'tax_number')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'country')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'zip')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'city')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<?= $form->field($model, 'updated_at')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,114 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Customer;
use common\components\CityNameTypeahead;
use common\components\CityZipTypeahead;
use common\components\CardNumberTypeahead;
use kartik\widgets\DatePicker;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="customer-form">
<?php $form = ActiveForm::begin(); ?>
<div class='row'>
<div class='col-md-3'>
<?php echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'birthdate')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'date_stundent_card_expire')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'tax_number')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'country')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-2'>
<?= $form->field($model, 'zip')->widget(CityZipTypeahead::className(),[
'pluginEvents' =>[
"typeahead:select" => "function(a,b) {
$('#customercreate-city').typeahead( 'val', b.name );
}",]
])?>
</div>
<div class='col-md-4'>
<?php echo $form->field($model, 'city')->widget(CityNameTypeahead::className(),[
'pluginEvents' =>[
"typeahead:select" => "function(a,b) {
$('#customercreate-zip').typeahead( 'val', b.zip );
}",]
])?>
</div>
</div>
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,118 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Customer;
use common\components\CityNameTypeahead;
use common\components\CityZipTypeahead;
use common\components\CardNumberTypeahead;
use kartik\widgets\DatePicker;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="customer-form">
<?php $form = ActiveForm::begin(); ?>
<div class='row'>
<div class='col-md-3'>
<?php //echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
<label><?php echo $model->getAttributeLabel('id_customer_card')?></label>
<div>
<?php echo $model->customerCardNumber ?>
</div>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'birthdate')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'date_stundent_card_expire')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'tax_number')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'country')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-2'>
<?= $form->field($model, 'zip')->widget(CityZipTypeahead::className(),[
'pluginEvents' =>[
"typeahead:select" => "function(a,b) {
$('#customercreate-city').typeahead( 'val', b.name );
}",]
])?>
</div>
<div class='col-md-4'>
<?php echo $form->field($model, 'city')->widget(CityNameTypeahead::className(),[
'pluginEvents' =>[
"typeahead:select" => "function(a,b) {
$('#customercreate-zip').typeahead( 'val', b.zip );
}",]
])?>
</div>
</div>
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,38 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\CustomerSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="customer-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class='row'>
<div class='col-md-4'>
<?= $form->field($model, 'cardNumber') ?>
</div>
<div class='col-md-4'>
<?php echo $form->field($model, 'name') ?>
</div>
<div class='col-md-4'>
<?php echo $form->field($model, 'email') ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/customer', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
$this->title = Yii::t('common/customer', 'Create Customer');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="customer-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form_create', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,58 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CustomerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/customer', 'Customers');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="customer-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/customer', 'Create Customer'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'customerCardNumber' ,
],
'name',
'email:email',
'phone',
'created_at:datetime',
['class' => 'yii\grid\ActionColumn',
'template' =>'{view} {update} {ticket/index-customer}',
'buttons' => [
'ticket/index-customer' => function ($url) { return Html::a( '<span class="glyphicon glyphicon-list-alt"> </span>', $url, [ 'title' => 'Bérletek' ] ); }
],
'urlCreator' =>function ($action, $model, $key, $index){
$params = is_array($key) ? $key : ['id' => (string) $key];
if ( $action == 'ticket/index-customer' ){
$today = \Yii::$app->formatter->asDate( strtotime('today UTC') );
$tomorrow = \Yii::$app->formatter->asDate( strtotime( 'tomorrow UTC' ));
$params['TicketSearch[start]'] = $today;
$params['TicketSearch[end]'] = $tomorrow;
}
$params[0] = $action;
return Url::toRoute($params);
}
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
$this->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');
?>
<div class="customer-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form_update', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,56 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="customer-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/customer', 'Update'), ['update', 'id' => $model->id_customer], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $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',
],
]) ?>
</div>

View File

@ -0,0 +1,32 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Discount;
/* @var $this yii\web\View */
/* @var $model common\models\Discount */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="discount-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/discount', "Active") ]) ?>
<?= $form->field($model, 'type')->dropDownList(Discount::types()) ?>
<?= $form->field($model, 'value')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/discount', 'Create') : Yii::t('common/discount', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,38 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\DiscountSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="discount-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_warehouse') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'status') ?>
<?= $form->field($model, 'type') ?>
<?= $form->field($model, 'value') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/discount', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Discount */
$this->title = Yii::t('common/discount', 'Create Discount');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/discount', 'Discounts'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="discount-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,48 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use common\components\RoleDefinition;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\DiscountSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/discount', 'Discounts');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="discount-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<?php if ( RoleDefinition::isAdmin() ) {?>
<p>
<?= Html::a(Yii::t('common/discount', 'Create Discount'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?php }?>
<?= GridView::widget([
'dataProvider' => $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}']),
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Discount */
$this->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');
?>
<div class="discount-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,45 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\components\RoleDefinition;
/* @var $this yii\web\View */
/* @var $model common\models\Discount */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/discount', 'Discounts'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="discount-view">
<h1><?= Html::encode($this->title) ?></h1>
<?php if ( RoleDefinition::isAdmin()) {?>
<p>
<?= Html::a(Yii::t('common/discount', 'Update'), ['update', 'id' => $model->id_discount], ['class' => 'btn btn-primary']) ?>
</p>
<?php }?>
<?= DetailView::widget([
'model' => $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',
],
]) ?>
</div>

Some files were not shown because too many files have changed in this diff Show More