add changes to account state
This commit is contained in:
parent
b04cbda645
commit
9145f21371
@ -45,7 +45,8 @@ class AdminMenuStructure{
|
||||
$items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ];
|
||||
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
|
||||
$items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
|
||||
$items[] = ['label' => 'Transfer', 'url' => ['/transfer/index'] ];
|
||||
$items[] = ['label' => 'Tranzakciók', 'url' => ['/transfer/index'] ];
|
||||
$items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
|
||||
|
||||
if ( count($items) > 0 ){
|
||||
$userMainMenu = ['label' => 'Beállítások', 'url' => null,
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use common\models\Account;
|
||||
use backend\models\AccountSearch;
|
||||
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;
|
||||
|
||||
/**
|
||||
* AccountController implements the CRUD actions for Account model.
|
||||
* AccountStateController implements the CRUD actions for AccountState model.
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
class AccountStateController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
@ -27,22 +29,29 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Account models.
|
||||
* Lists all AccountState models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new AccountSearch();
|
||||
$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 Account model.
|
||||
* Displays a single AccountState model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
@ -54,16 +63,16 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Account model.
|
||||
* 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 Account();
|
||||
$model = new AccountState();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_account]);
|
||||
return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
} else {
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
@ -72,7 +81,7 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Account model.
|
||||
* Updates an existing AccountState model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
@ -82,7 +91,7 @@ class AccountController extends Controller
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_account]);
|
||||
return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
@ -91,7 +100,7 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Account model.
|
||||
* Deletes an existing AccountState model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
@ -104,15 +113,15 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Account model based on its primary key value.
|
||||
* 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 Account the loaded model
|
||||
* @return AccountState the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Account::findOne($id)) !== null) {
|
||||
if (($model = AccountState::findOne($id)) !== null) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
@ -11,12 +11,15 @@ use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use backend\models\UserUpdate;
|
||||
use common\models\Account;
|
||||
use common\models\UserAccountAssignment;
|
||||
|
||||
/**
|
||||
* UserController implements the CRUD actions for User model.
|
||||
*/
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
@ -37,6 +40,8 @@ class UserController extends Controller
|
||||
{
|
||||
$searchModel = new UserSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
@ -64,14 +69,35 @@ class UserController extends Controller
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new UserCreate();
|
||||
|
||||
$accounts = Account::readAccounts();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
} else {
|
||||
|
||||
$this->updateAccountAssignments($model);
|
||||
|
||||
// return $this->redirect(['view', 'id' => $model->id]);
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,14 +113,29 @@ class UserController extends Controller
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
82
backend/models/AccountStateSearch.php
Normal file
82
backend/models/AccountStateSearch.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\AccountState;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@ -66,6 +66,7 @@ class TransferSearch extends Transfer
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
// $query->distinct();
|
||||
$selectObjectName = "";
|
||||
$selectObjectName .= " case when transfer.type = " .self::TYPE_PRODUCT ." then product.name else ticket_type.name end as object_name";
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ class UserCreate extends User{
|
||||
|
||||
public $password_plain;
|
||||
public $password_repeat;
|
||||
public $selected_accounts = [];
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@ -16,11 +17,17 @@ class UserCreate extends User{
|
||||
{
|
||||
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' ]
|
||||
[['password_repeat'] ,'validatePasswordRepeat' ],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ use common\models\User;
|
||||
class UserUpdate extends User {
|
||||
public $password_plain;
|
||||
public $password_repeat;
|
||||
public $selected_accounts = [];
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@ -21,9 +22,16 @@ class UserUpdate extends User {
|
||||
['email' ,'unique' , 'targetClass' => User::className(), 'targetAttribute' => 'email'],
|
||||
['username' ,'unique', 'targetClass' => User::className(), 'targetAttribute' => 'username'],
|
||||
[['password_plain' ,'password_repeat'] ,'string','min' =>6 ],
|
||||
[['password_repeat'] ,'validatePasswordRepeat' ]
|
||||
[['password_repeat'] ,'validatePasswordRepeat' ],
|
||||
['selected_accounts',function ($attribute, $params) {
|
||||
if (!is_array($this->$attribute)) {
|
||||
$this->addError($attribute, 'Invalid array');
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @formatter:on
|
||||
*/
|
||||
|
||||
55
backend/views/account-state/_form.php
Normal file
55
backend/views/account-state/_form.php
Normal 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>
|
||||
13
backend/views/account-state/_item_view.php
Normal file
13
backend/views/account-state/_item_view.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
use frontend\components\AccountStateBanknoteCountWidget;
|
||||
use yii\base\Widget;
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo AccountStateBanknoteCountWidget::widget([
|
||||
'model' => $model,
|
||||
]);
|
||||
?>
|
||||
|
||||
|
||||
68
backend/views/account-state/_search.php
Normal file
68
backend/views/account-state/_search.php
Normal 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>
|
||||
21
backend/views/account-state/create.php
Normal file
21
backend/views/account-state/create.php
Normal 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>
|
||||
39
backend/views/account-state/index.php
Normal file
39
backend/views/account-state/index.php
Normal 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>
|
||||
23
backend/views/account-state/update.php
Normal file
23
backend/views/account-state/update.php
Normal 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>
|
||||
56
backend/views/account-state/view.php
Normal file
56
backend/views/account-state/view.php
Normal 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>
|
||||
@ -2,6 +2,10 @@
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\grid\GridView;
|
||||
use yii\base\Widget;
|
||||
use yii\base\Object;
|
||||
use yii\data\ArrayDataProvider;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\User */
|
||||
@ -18,6 +22,41 @@ use yii\widgets\ActiveForm;
|
||||
<?= $form->field($model, 'password_plain')->passwordInput() ?>
|
||||
<?= $form->field($model, 'password_repeat')->passwordInput() ?>
|
||||
|
||||
<?php
|
||||
|
||||
$selectedAccounts = $model->selected_accounts;
|
||||
|
||||
?>
|
||||
|
||||
<h3>Engedélyezett kasszák</h3>
|
||||
<?php echo GridView::widget([
|
||||
'dataProvider' => new ArrayDataProvider( [
|
||||
'allModels' => $accounts,
|
||||
'sort' => false,
|
||||
'pagination' => false,
|
||||
]),
|
||||
'columns' => [
|
||||
[
|
||||
'class' => 'yii\grid\CheckboxColumn',
|
||||
'name' => (new ReflectionClass( $model->classname() ))->getShortName() . '[selected_accounts]',
|
||||
'checkboxOptions' => function ($model, $key, $index, $column) use ($selectedAccounts){
|
||||
$result = [];
|
||||
$result['value'] = $model->id_account ;
|
||||
|
||||
if ( isset($selectedAccounts) ){
|
||||
if ( is_array($selectedAccounts) ){
|
||||
if ( array_search($model->id_account , $selectedAccounts ) !== false){
|
||||
$result['checked'] = 'checked' ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
],
|
||||
[ 'attribute' => 'name' ],
|
||||
],
|
||||
])?>
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Mentés') : Yii::t('app', 'Mentés'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
@ -16,6 +16,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
|
||||
@ -18,6 +18,7 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'Update');
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
|
||||
49
common/components/ArrayValidator.php
Normal file
49
common/components/ArrayValidator.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace common\components;
|
||||
|
||||
use yii\base\InvalidConfigException;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
class ArrayValidator extends Validator
|
||||
{
|
||||
|
||||
public $arrayAttributeName;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
if ($this->message === null) {
|
||||
$this->message = Yii::t('yii', '{attribute} is invalid.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function validateAttribute($model, $attribute)
|
||||
{
|
||||
$value = $model->$attribute;
|
||||
if (!is_array($value)) {
|
||||
$this->addError($model, $attribute, $this->message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function validateValue($value)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
return [Yii::t('yii', '{attribute} is invalid.'), []];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -17,6 +17,12 @@
|
||||
* NOTE: this file must be saved in UTF-8 encoding.
|
||||
*/
|
||||
return [
|
||||
'Account' => 'Kassza',
|
||||
'All' => 'Mind',
|
||||
'Money total' => 'Összesen',
|
||||
'Product' => 'Termék',
|
||||
'Ticket' => 'Bérlet',
|
||||
'Total' => 'Összesen',
|
||||
'Comment' => 'Megjegyzés',
|
||||
'Count' => 'Mennyiség',
|
||||
'Created At' => 'Dátum',
|
||||
|
||||
@ -72,6 +72,10 @@ class Account extends \yii\db\ActiveRecord
|
||||
];
|
||||
}
|
||||
|
||||
public function getUserAccountAssignments(){
|
||||
return $this->hasMany(UserAccountAssignment::className(), ['id_account' => 'id_account']);
|
||||
}
|
||||
|
||||
static function statuses() {
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t('common/account', 'Active'),
|
||||
@ -123,6 +127,22 @@ class Account extends \yii\db\ActiveRecord
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
public static function read($forceIncludeAccount = null){
|
||||
$accounts = null;
|
||||
$query = Account::find();
|
||||
$query->innerJoinWith('userAccountAssignments');
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
||||
$query->andWhere(['status' => Account::STATUS_ACTIVE]);
|
||||
if ( $forceIncludeAccount == null){
|
||||
$query->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||
}else{
|
||||
$query->andWhere( ['or', ['status' => Account::STATUS_ACTIVE], ['id_account' => $forceIncludeAccount ] ])->all();
|
||||
}
|
||||
|
||||
$accounts = $query->all();
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
227
common/models/AccountState.php
Normal file
227
common/models/AccountState.php
Normal file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\db\QueryBuilder;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* This is the model class for table "account_state".
|
||||
*
|
||||
* @property integer $id_account_state
|
||||
* @property integer $id_account
|
||||
* @property integer $type
|
||||
* @property integer $money
|
||||
* @property integer $banknote_5_ft
|
||||
* @property integer $banknote_10_ft
|
||||
* @property integer $banknote_20_ft
|
||||
* @property integer $banknote_50_ft
|
||||
* @property integer $banknote_100_ft
|
||||
* @property integer $banknote_200_ft
|
||||
* @property integer $banknote_500_ft
|
||||
* @property integer $banknote_1000_ft
|
||||
* @property integer $banknote_2000_ft
|
||||
* @property integer $banknote_5000_ft
|
||||
* @property integer $banknote_10000_ft
|
||||
* @property integer $banknote_20000_ft
|
||||
* @property integer $id_user
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class AccountState extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
|
||||
const TYPE_OPEN = 10;
|
||||
const TYPE_CLOSE = 20;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'account_state';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_account','money' ], 'required'],
|
||||
[['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' ], 'integer'],
|
||||
[['comment' ], 'string' ,'max' => 255],
|
||||
[['prev_state' ], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_account_state' => Yii::t('common/account_state', 'Id Account State'),
|
||||
'id_account' => Yii::t('common/account_state', 'Id Account'),
|
||||
'type' => Yii::t('common/account_state', 'Type'),
|
||||
'money' => Yii::t('common/account_state', 'Money'),
|
||||
'banknote_5_ft' => Yii::t('common/account_state', 'Banknote 5 Ft'),
|
||||
'banknote_10_ft' => Yii::t('common/account_state', 'Banknote 10 Ft'),
|
||||
'banknote_20_ft' => Yii::t('common/account_state', 'Banknote 20 Ft'),
|
||||
'banknote_50_ft' => Yii::t('common/account_state', 'Banknote 50 Ft'),
|
||||
'banknote_100_ft' => Yii::t('common/account_state', 'Banknote 100 Ft'),
|
||||
'banknote_200_ft' => Yii::t('common/account_state', 'Banknote 200 Ft'),
|
||||
'banknote_500_ft' => Yii::t('common/account_state', 'Banknote 500 Ft'),
|
||||
'banknote_1000_ft' => Yii::t('common/account_state', 'Banknote 1000 Ft'),
|
||||
'banknote_2000_ft' => Yii::t('common/account_state', 'Banknote 2000 Ft'),
|
||||
'banknote_5000_ft' => Yii::t('common/account_state', 'Banknote 5000 Ft'),
|
||||
'banknote_10000_ft' => Yii::t('common/account_state', 'Banknote 10000 Ft'),
|
||||
'banknote_20000_ft' => Yii::t('common/account_state', 'Banknote 20000 Ft'),
|
||||
'id_user' => Yii::t('common/account_state', 'Id User'),
|
||||
'created_at' => Yii::t('common/account_state', 'Created At'),
|
||||
'updated_at' => Yii::t('common/account_state', 'Updated At'),
|
||||
'comment' => Yii::t('common/account_state', 'Comment'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function banknoteValues()
|
||||
{
|
||||
return [
|
||||
'banknote_5_ft' => 5,
|
||||
'banknote_10_ft' => 10,
|
||||
'banknote_20_ft' => 20,
|
||||
'banknote_50_ft' => 50,
|
||||
'banknote_100_ft' => 100,
|
||||
'banknote_200_ft' => 200,
|
||||
'banknote_500_ft' => 500,
|
||||
'banknote_1000_ft' => 1000,
|
||||
'banknote_2000_ft' => 2000,
|
||||
'banknote_5000_ft' => 5000,
|
||||
'banknote_10000_ft' => 10000,
|
||||
'banknote_20000_ft' => 20000,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getAccount(){
|
||||
return $this->hasOne( Account::className(), ["id_account" =>"id_account" ] ) ;
|
||||
}
|
||||
|
||||
public function getAccountName(){
|
||||
$result = "";
|
||||
$account = $this->account;
|
||||
if (isset($account)){
|
||||
$result = $account->name;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getUser(){
|
||||
return $this->hasOne( User::className(), ["id" =>"id_user" ] );
|
||||
}
|
||||
|
||||
public function getUserName(){
|
||||
$result = "";
|
||||
$user = $this->user;
|
||||
if (isset($this->user)){
|
||||
$result = $user->username;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function getTypeName(){
|
||||
$result = "";
|
||||
$type = AccountState::findType($this->type);
|
||||
if (isset($type)){
|
||||
$result = $type;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function types(){
|
||||
return [
|
||||
self::TYPE_OPEN => Yii::t('common/account-state','Open'),
|
||||
self::TYPE_CLOSE => Yii::t('common/account-state','Close'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function findType($type){
|
||||
$result = null;
|
||||
$types = self::types();
|
||||
if ( array_key_exists($type, $types)){
|
||||
$result = $types[ $type ];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read last accountstates
|
||||
* @param $type int the type of accountstate to load
|
||||
* @param $user $id of user to load the account
|
||||
* */
|
||||
public static function readLast($type, $user = null){
|
||||
$result = null;
|
||||
$query = AccountState::find();
|
||||
//filter user
|
||||
if ( isset($user)){
|
||||
$query->innerJoinWith("account");
|
||||
$query->innerJoinWith("account.userAccountAssignments");
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
||||
}
|
||||
//filter type
|
||||
if ( isset($type)){
|
||||
$query->andWhere(['account_state.type' => $type]);
|
||||
}
|
||||
//filter last
|
||||
$query->join("INNER JOIN ",
|
||||
"(select max(created_at) as cdate, id_account from account_state group by id_account) as sq1"
|
||||
,"sq1.cdate = account_state.created_at and sq1.id_account = account_state.id_account");
|
||||
$query->orderBy(['created_at' => SORT_DESC]);
|
||||
$result = $query->all();
|
||||
return $result;
|
||||
}
|
||||
|
||||
function beforeSave($insert){
|
||||
$result = parent::beforeSave($insert);
|
||||
if ( $result ){
|
||||
$prev = null;
|
||||
|
||||
if ( isset($this->prev_state) ){
|
||||
$prev = AccountState::findOne($this->prev_state);
|
||||
}
|
||||
|
||||
if ( $prev != null){
|
||||
$this->prev_money = $prev->money;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function hasDifferenceToPrevState(){
|
||||
$result = false;
|
||||
if ( isset( $this->prev_state ) ){
|
||||
$result = $this->prev_money != $this->money;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function readLastForUser($type){
|
||||
return static::readLast($type, Yii::$app->user->id);
|
||||
}
|
||||
|
||||
|
||||
public static function modelsToArray($models){
|
||||
return ArrayHelper::toArray($models, [
|
||||
'common\models\AccountState' => [
|
||||
'id_account_state',
|
||||
'id_account',
|
||||
'money',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@ -35,6 +35,9 @@ class Transfer extends \yii\db\ActiveRecord
|
||||
const STATUS_NOT_PAID = 10;
|
||||
const STATUS_PAID = 20;
|
||||
|
||||
const DIRECTION_IN = 10;// MONEY GOES OUT FROM ACCOUNT ( COMPANY LOST MONEY )
|
||||
const DIRECTION_OUT = 20;//MONEY GOES IN TO THE ACCOUNT ( COMPANY EARN MONEY )
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@ -62,6 +65,7 @@ class Transfer extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
'id_transfer' => Yii::t('common/transfer', 'Id Transfer'),
|
||||
'id_account' => Yii::t('common/transfer', 'Account'),
|
||||
'id_discount' => Yii::t('common/transfer', 'Id Discount'),
|
||||
'id_currency' => Yii::t('common/transfer', 'Id Currency'),
|
||||
'id_object' => Yii::t('common/transfer', 'Id Object'),
|
||||
|
||||
@ -186,6 +186,10 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
$this->password_reset_token = null;
|
||||
}
|
||||
|
||||
public function getUserAccountAssignments(){
|
||||
return $this->hasMany(UserAccountAssignment::className(), ['id_user' =>'id']);
|
||||
}
|
||||
|
||||
static function statuses() {
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t('app', 'Aktív'),
|
||||
|
||||
45
common/models/UserAccountAssignment.php
Normal file
45
common/models/UserAccountAssignment.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "user_account_assignment".
|
||||
*
|
||||
* @property integer $id_user_account_assignment
|
||||
* @property integer $id_user
|
||||
* @property integer $id_account
|
||||
*/
|
||||
class UserAccountAssignment extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'user_account_assignment';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_user', 'id_account'], 'integer']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_user_account_assignment' => Yii::t('common/user-account-assignment', 'Id User Account Assignment'),
|
||||
'id_user' => Yii::t('common/user-account-assignment', 'Id User'),
|
||||
'id_account' => Yii::t('common/user-account-assignment', 'Id Account'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,8 @@
|
||||
"kartik-v/yii2-widget-typeahead": "*",
|
||||
"bower-asset/remarkable-bootstrap-notify": "^3.1",
|
||||
"yiisoft/yii2-jui": "^2.0",
|
||||
"bower-asset/moment": "^2.10"
|
||||
"bower-asset/moment": "^2.10",
|
||||
"bower-asset/accounting": "^0.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"yiisoft/yii2-codeception": "*",
|
||||
|
||||
18
composer.lock
generated
18
composer.lock
generated
@ -4,8 +4,24 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "ade53c29b13f5eaa8367e21defe51905",
|
||||
"hash": "357aedc9b70234f38508aac35c6272cd",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bower-asset/accounting",
|
||||
"version": "v0.3.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/josscrowcroft/accounting.js.git",
|
||||
"reference": "9ff4a4022e5c08f028d652d2b0ba1d4b65588bde"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/josscrowcroft/accounting.js/zipball/9ff4a4022e5c08f028d652d2b0ba1d4b65588bde",
|
||||
"reference": "9ff4a4022e5c08f028d652d2b0ba1d4b65588bde",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "bower-asset-library"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/bootstrap",
|
||||
"version": "v3.3.5",
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m151013_154204_add__table__user__account_assignment extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
|
||||
$this->createTable('{{%user_account_assignment}}', [
|
||||
'id_user_account_assignment' => $this->primaryKey(),
|
||||
'id_user' => $this->integer(11) ,
|
||||
'id_account' => $this->integer(11) ,
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m151013_154204_add__table__user__account_assignment cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m151014_053236_add__table__account_state extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
|
||||
$this->createTable('{{%account_state}}', [
|
||||
'id_account_state' => $this->primaryKey(),
|
||||
'id_account' => $this->integer(11),
|
||||
'type' => $this->smallInteger(),
|
||||
'money' => $this->integer(11),
|
||||
'banknote_5_ft' => $this->integer(11),
|
||||
'banknote_10_ft' => $this->integer(11),
|
||||
'banknote_20_ft' => $this->integer(11),
|
||||
'banknote_50_ft' => $this->integer(11),
|
||||
'banknote_100_ft' => $this->integer(11),
|
||||
'banknote_200_ft' => $this->integer(11),
|
||||
'banknote_500_ft' => $this->integer(11),
|
||||
'banknote_1000_ft' => $this->integer(11),
|
||||
'banknote_2000_ft' => $this->integer(11),
|
||||
'banknote_5000_ft' => $this->integer(11),
|
||||
'banknote_10000_ft' => $this->integer(11),
|
||||
'banknote_20000_ft' => $this->integer(11),
|
||||
'id_user' => $this->integer(11),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m151014_053236_add__table__account_state cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m151016_100724_alter__table__account_state__add__columns__comment__prev_state__prev_money extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn('account_state','comment', 'varchar(255)' );
|
||||
$this->addColumn('account_state','prev_state', 'int(11)' );
|
||||
$this->addColumn('account_state','prev_money', 'int(11)' );
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m151016_100724_alter__table__account_state__add__columns__comment__prev_state__prev_money cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m151018_103040_alter__table_transfer__add_column__dircetion extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn('transfer', "direction", "int(11)");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m151018_103040_alter__table_transfer__add_column__dircetion cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
29
frontend/assets/AccountStateAsset.php
Normal file
29
frontend/assets/AccountStateAsset.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace frontend\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
/**
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class AccountStateAsset extends AssetBundle
|
||||
{
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/accountstate.js',
|
||||
];
|
||||
public $depends = [
|
||||
'frontend\assets\AppAsset',
|
||||
'frontend\assets\AccountingAsset',
|
||||
];
|
||||
}
|
||||
16
frontend/assets/AccountingAsset.php
Normal file
16
frontend/assets/AccountingAsset.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace frontend\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
class AccountingAsset extends AssetBundle
|
||||
{
|
||||
public $sourcePath = '@bower';
|
||||
|
||||
public $js = [
|
||||
'accounting/accounting.min.js'
|
||||
];
|
||||
|
||||
public $depends = [
|
||||
];
|
||||
}
|
||||
173
frontend/components/AccountStateBanknoteCountWidget.php
Normal file
173
frontend/components/AccountStateBanknoteCountWidget.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
namespace frontend\components;
|
||||
|
||||
use yii\base\Widget;
|
||||
use common\models\AccountState;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
use yii\grid\GridView;
|
||||
use yii\base\Object;
|
||||
use yii\data\ArrayDataProvider;
|
||||
|
||||
class AccountStateBanknoteCountWidget extends Widget{
|
||||
|
||||
public $model;
|
||||
public $layout;
|
||||
|
||||
public function run(){
|
||||
|
||||
$panelStyleClas = 'panel-default';
|
||||
if ( $this->model->hasDifferenceToPrevState()){
|
||||
$panelStyleClas = 'panel-danger';
|
||||
}
|
||||
|
||||
$s = "";
|
||||
$s .= Html::beginTag("div",['class' => 'panel '.$panelStyleClas] );
|
||||
$s .= Html::beginTag("div",['class' => 'panel-heading '] );
|
||||
$s .= "Kassza művelet - " . $this->model->typeName;
|
||||
$s .= Html::endTag("div");
|
||||
$s .= Html::beginTag("div",['class' => 'panel-body '] );
|
||||
$s .= $this->generateInfoRow();
|
||||
$s .= $this->generateNotes();
|
||||
$s .= $this->generateComment();
|
||||
$s .= Html::endTag("div");
|
||||
$s .= Html::endTag("div");
|
||||
|
||||
echo $s;
|
||||
}
|
||||
|
||||
|
||||
protected function generateInfoRow(){
|
||||
$s = "";
|
||||
|
||||
$s .= Html::beginTag("div", ['class' => 'row', 'style' => 'margin-top: 6px;']);
|
||||
$s .= Html::beginTag("div", ['class' => 'col-md-6']);
|
||||
$s .= DetailView::widget([
|
||||
'model' => $this->model,
|
||||
'attributes' => [
|
||||
[
|
||||
'attribute' => 'id_user',
|
||||
'value' => $this->model->userName
|
||||
],
|
||||
'created_at:datetime',
|
||||
]
|
||||
]);
|
||||
|
||||
$s .= Html::endTag("div");
|
||||
$s .= Html::beginTag("div", ['class' => 'col-md-6']);
|
||||
$s .= DetailView::widget([
|
||||
'model' => $this->model,
|
||||
'attributes' => [
|
||||
'typeName',
|
||||
'accountName',
|
||||
'money:integer'
|
||||
]
|
||||
]);
|
||||
|
||||
$s .= Html::endTag("div");
|
||||
$s .= Html::endTag("div");
|
||||
|
||||
return $s;
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function generateComment(){
|
||||
$s = "";
|
||||
if ( isset($this->model->comment) && !empty($this->model->comment)){
|
||||
|
||||
$s .= Html::beginTag("div", ['class' => 'row', 'style' => 'margin-top: 6px;']);
|
||||
$s .= Html::beginTag("div", ['class' => 'col-md-12']);
|
||||
$s .= Html::beginTag("table", ['class' => 'table table-striped table-bordered']);
|
||||
$s .= Html::beginTag("thead", ['class' => ' ']);
|
||||
$s .= Html::beginTag("tr", ['class' => ' ']);
|
||||
$s .= Html::beginTag("th", ['class' => ' ']);
|
||||
$s .= $this->model->getAttributeLabel('comment');
|
||||
$s .= Html::endTag("tr");
|
||||
$s .= Html::endTag("th");
|
||||
$s .= Html::endTag("thead");
|
||||
$s .= Html::beginTag("tbody", ['class' => ' ']);
|
||||
$s .= Html::beginTag("tr", ['class' => ' ']);
|
||||
$s .= Html::beginTag("td", ['class' => ' ']);
|
||||
$s .= $this->model->comment;
|
||||
$s .= Html::endTag("td");
|
||||
$s .= Html::endTag("th");
|
||||
$s .= Html::endTag("tbody");
|
||||
$s .= Html::endTag("table");
|
||||
$s .= Html::endTag("div");
|
||||
$s .= Html::endTag("div");
|
||||
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
protected function generateNotes(){
|
||||
$s = "";
|
||||
$s .= Html::beginTag("div", ['class' => 'row', 'style' => 'margin-top: 6px;']);
|
||||
$s .= Html::beginTag("div", ['class' => 'col-md-4']);
|
||||
$s .= $this->generateBanknoteGrid( [ 'banknote_5_ft','banknote_10_ft','banknote_20_ft','banknote_50_ft' ]);
|
||||
$s .= Html::endTag("div");
|
||||
$s .= Html::beginTag("div", ['class' => 'col-md-4']);
|
||||
$s .= $this->generateBanknoteGrid( [ 'banknote_100_ft','banknote_200_ft','banknote_500_ft','banknote_1000_ft' ]);
|
||||
$s .= Html::endTag("div");
|
||||
$s .= Html::beginTag("div", ['class' => 'col-md-4']);
|
||||
$s .= $this->generateBanknoteGrid( [ 'banknote_2000_ft','banknote_5000_ft','banknote_10000_ft','banknote_20000_ft' ]);
|
||||
$s .= Html::endTag("div");
|
||||
$s .= Html::endTag("div");
|
||||
return $s;
|
||||
}
|
||||
|
||||
protected function generateBanknoteGrid($attributes){
|
||||
|
||||
return $this->generateBanknoteColumn( $this->mkColumnData($attributes));
|
||||
}
|
||||
|
||||
protected function mkColumnData( $attributes){
|
||||
|
||||
$values = AccountState::banknoteValues();
|
||||
$items = [];
|
||||
foreach ($attributes as $note){
|
||||
$value = $values[$note];
|
||||
$count = $this->model->$note;
|
||||
if ( !isset($count) || empty($count)){
|
||||
$count = 0;
|
||||
}
|
||||
$value = \Yii::$app->formatter->asInteger($value);
|
||||
$item = [
|
||||
'note' => $value . " Ft",
|
||||
'count' => $count
|
||||
];
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
protected function generateBanknoteColumn($data){
|
||||
$dp = new ArrayDataProvider(
|
||||
[
|
||||
'allModels' => $data,
|
||||
'sort' => false,
|
||||
'pagination' => false
|
||||
]
|
||||
);
|
||||
$s = GridView::widget([
|
||||
'dataProvider' => $dp,
|
||||
'layout' => '{items}',
|
||||
'options' => ['class' => 'grid-view notes-view'],
|
||||
'columns' =>[
|
||||
[
|
||||
'value' => 'note',
|
||||
'label' => 'Címlet'
|
||||
],
|
||||
[
|
||||
'value' => 'count',
|
||||
'label' => 'Db'
|
||||
],
|
||||
]
|
||||
]);
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -23,13 +23,21 @@ class FrontendMenuStructure{
|
||||
|
||||
|
||||
protected function isLogged(){
|
||||
return Yii::$app->user->isGuest;
|
||||
return !Yii::$app->user->isGuest;
|
||||
}
|
||||
|
||||
|
||||
protected function addRecepcio(){
|
||||
if ( $this->isLogged() ){
|
||||
$this->menuItems[] = ['label' => 'Recepcio', 'url' => ['/customer/reception'] ];
|
||||
$this->menuItems[] = ['label' => 'Kassza',
|
||||
'items' => [
|
||||
['label' => 'Account states', 'url' => ['/account-state/index'] ],
|
||||
['label' => 'Open account state', 'url' => ['/account-state/open'] ],
|
||||
['label' => 'Close account state', 'url' => ['/account-state/close'] ],
|
||||
]
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ use Yii;
|
||||
use common\models\Order;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\AccountState;
|
||||
|
||||
class HtmlHelper{
|
||||
|
||||
@ -75,5 +76,13 @@ class HtmlHelper{
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function formatMoney($money){
|
||||
$s = $money;
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
175
frontend/controllers/AccountStateController.php
Normal file
175
frontend/controllers/AccountStateController.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use common\models\AccountState;
|
||||
use frontend\models\AccountstateSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use common\models\Account;
|
||||
|
||||
/**
|
||||
* AccountStateController implements the CRUD actions for AccountState model.
|
||||
*/
|
||||
class AccountStateController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all AccountState models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new AccountstateSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 actionOpen()
|
||||
{
|
||||
|
||||
$lastStates = AccountState::readLastForUser(AccountState::TYPE_CLOSE );
|
||||
$lastStates = AccountState::modelsToArray($lastStates);
|
||||
|
||||
$model = new AccountState();
|
||||
$model->type = AccountState::TYPE_OPEN;
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
return $this->redirect(['index' ]);
|
||||
} else {
|
||||
|
||||
$accounts = Account::read();
|
||||
|
||||
return $this->render('open', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'lastStates' => $lastStates,
|
||||
]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates a new AccountState model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionClose()
|
||||
{
|
||||
$model = new AccountState();
|
||||
$model->type = AccountState::TYPE_CLOSE;
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['index' ]);
|
||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
} else {
|
||||
|
||||
$accounts = Account::read();
|
||||
|
||||
return $this->render('close', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
66
frontend/models/AccountstateSearch.php
Normal file
66
frontend/models/AccountstateSearch.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\AccountState;
|
||||
|
||||
/**
|
||||
* AccountstateSearch represents the model behind the search form about `common\models\AccountState`.
|
||||
*/
|
||||
class AccountstateSearch extends AccountState
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
||||
$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->innerJoinWith('account');
|
||||
$query->innerJoinWith('account.userAccountAssignments');
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
||||
$query->orderBy( 'created_at desc' );
|
||||
|
||||
$query->limit = 20;
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
57
frontend/views/account-state/_form.php
Normal file
57
frontend/views/account-state/_form.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?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, 'id_user')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'created_at')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'updated_at')->textInput() ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('frontend/account-state', 'Create') : Yii::t('frontend/account-state', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
63
frontend/views/account-state/_form_close.php
Normal file
63
frontend/views/account-state/_form_close.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use frontend\components\HtmlHelper;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<div class="account-state-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
<div class='row'>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'id_account')->dropDownList( HtmlHelper::mkAccountOptions($accounts) ) ?>
|
||||
</div>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'money')->textInput(['class' => 'form-control text-right']); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo $this->render('_notes',[ 'form' => $form, 'model' => $model])?>
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
<?php echo $model->getAttributeLabel('money') ?>
|
||||
</th>
|
||||
<td class="text-right">
|
||||
<span class="money "></span> Ft
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
<?php echo Yii::t('frontend/account-state', "Notes total")?>
|
||||
</th>
|
||||
<td class="text-right">
|
||||
<span class="notes-total "></span> Ft
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
<?php echo Yii::t('frontend/account-state', "Difference total")?>
|
||||
</th>
|
||||
<td class="text-right">
|
||||
<span class="diff-total "></span> Ft
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?= $form->field($model, 'comment')->textarea() ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton( Yii::t('frontend/account-state', 'Close account'), ['class' => 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
80
frontend/views/account-state/_form_open.php
Normal file
80
frontend/views/account-state/_form_open.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use frontend\components\HtmlHelper;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="account-state-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?php echo Html::activeHiddenInput($model, "prev_state") ?>
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'id_account')->dropDownList( HtmlHelper::mkAccountOptions($accounts) ) ?>
|
||||
</div>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'money')->textInput(['class' => 'form-control text-right']); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo $this->render('_notes',[ 'form' => $form, 'model' => $model])?>
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
<?php echo $model->getAttributeLabel('money') ?>
|
||||
</th>
|
||||
<td class="text-right">
|
||||
<span class="money "></span> Ft
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
<?php echo Yii::t('frontend/account-state', "Notes total")?>
|
||||
</th>
|
||||
<td class="text-right">
|
||||
<span class="notes-total "></span> Ft
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
<?php echo Yii::t('frontend/account-state', "Difference total")?>
|
||||
</th>
|
||||
<td class="text-right">
|
||||
<span class="diff-total "></span> Ft
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
<?php echo Yii::t("frontend/account-state", "Last closing money")?>
|
||||
</th>
|
||||
<td class="text-right">
|
||||
<span class="last-closing-money "></span> Ft
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
<?php echo Yii::t('frontend/account-state', "Difference closing money")?>
|
||||
</th>
|
||||
<td class="text-right">
|
||||
<span class="diff-closing "></span> Ft
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?= $form->field($model, 'comment')->textarea() ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('frontend/account-state', 'Create') : Yii::t('frontend/account-state', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
13
frontend/views/account-state/_item_view.php
Normal file
13
frontend/views/account-state/_item_view.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
use frontend\components\AccountStateBanknoteCountWidget;
|
||||
use yii\base\Widget;
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo AccountStateBanknoteCountWidget::widget([
|
||||
'model' => $model,
|
||||
]);
|
||||
?>
|
||||
|
||||
|
||||
31
frontend/views/account-state/_notes.php
Normal file
31
frontend/views/account-state/_notes.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
?>
|
||||
<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<?= $form->field($model, 'banknote_5_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '5']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_10_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '10']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_20_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '15']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_50_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '20']) ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?= $form->field($model, 'banknote_100_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '100']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_200_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '200']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_500_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '500']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_1000_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '1000']) ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?= $form->field($model, 'banknote_2000_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '2000']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_5000_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '5000']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_10000_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '10000']) ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_20000_ft')->textInput([ 'class' => 'form-control note-input text-right', 'data-value' => '20000']) ?>
|
||||
</div>
|
||||
</div>
|
||||
63
frontend/views/account-state/_search.php
Normal file
63
frontend/views/account-state/_search.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model frontend\models\AccountstateSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="account-state-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id_account_state') ?>
|
||||
|
||||
<?= $form->field($model, 'id_account') ?>
|
||||
|
||||
<?= $form->field($model, 'type') ?>
|
||||
|
||||
<?= $form->field($model, 'money') ?>
|
||||
|
||||
<?= $form->field($model, 'banknote_5_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_10_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_20_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_50_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_100_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_200_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_500_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_1000_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_2000_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_5000_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_10000_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'banknote_20000_ft') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'id_user') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('frontend/account-state', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton(Yii::t('frontend/account-state', 'Reset'), ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
28
frontend/views/account-state/close.php
Normal file
28
frontend/views/account-state/close.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use frontend\assets\AccountStateAsset;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
|
||||
$this->title = Yii::t('frontend/account-state', 'Close Account State');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account-state', 'Account States'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
AccountStateAsset::register($this);
|
||||
$options = [];
|
||||
|
||||
$this->registerJs ( 'new AccountState( '. json_encode($options).');' );
|
||||
?>
|
||||
<div class="account-state-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form_close', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
21
frontend/views/account-state/create.php
Normal file
21
frontend/views/account-state/create.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
|
||||
$this->title = Yii::t('frontend/account-state', 'Create Account State');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/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>
|
||||
38
frontend/views/account-state/index.php
Normal file
38
frontend/views/account-state/index.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\ListView;
|
||||
use yii\base\Widget;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel frontend\models\AccountstateSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t('frontend/account-state', 'Account States');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
|
||||
<style>
|
||||
.notes-view table thead th,
|
||||
.notes-view table td{
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div class="account-state-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('frontend/account-state', 'Open Account State'), ['open'], ['class' => 'btn btn-success']) ?>
|
||||
<?= Html::a(Yii::t('frontend/account-state', 'Close Account State'), ['close'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?php echo ListView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'itemView' => '_item_view'
|
||||
])?>
|
||||
|
||||
</div>
|
||||
29
frontend/views/account-state/open.php
Normal file
29
frontend/views/account-state/open.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use frontend\assets\AccountStateAsset;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
|
||||
$this->title = Yii::t('frontend/account-state', 'Open Account State');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account-state', 'Account States'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
AccountStateAsset::register($this);
|
||||
$options = [];
|
||||
$options['last_states'] = $lastStates;
|
||||
$options['open'] = true;
|
||||
$this->registerJs ( 'new AccountState( '. json_encode($options).');' );
|
||||
?>
|
||||
<div class="account-state-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form_open', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
23
frontend/views/account-state/update.php
Normal file
23
frontend/views/account-state/update.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
|
||||
$this->title = Yii::t('frontend/account-state', 'Update {modelClass}: ', [
|
||||
'modelClass' => 'Account State',
|
||||
]) . ' ' . $model->id_account_state;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/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('frontend/account-state', 'Update');
|
||||
?>
|
||||
<div class="account-state-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
53
frontend/views/account-state/view.php
Normal file
53
frontend/views/account-state/view.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?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('frontend/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('frontend/account-state', 'Update'), ['update', 'id' => $model->id_account_state], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a(Yii::t('frontend/account-state', 'Delete'), ['delete', 'id' => $model->id_account_state], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => Yii::t('frontend/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',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
142
frontend/web/js/accountstate.js
Normal file
142
frontend/web/js/accountstate.js
Normal file
@ -0,0 +1,142 @@
|
||||
function AccountState(o){
|
||||
|
||||
/**reference for the instance*/
|
||||
var app = this;
|
||||
|
||||
var total = 0;// sum of banknotes
|
||||
var money = 0;//value of money field
|
||||
var diff = 0;//diff of total and money
|
||||
var id_account;//selected account
|
||||
var last_state;//last state of selected account
|
||||
var last_money;//last moeny on selected account
|
||||
var last_diff;// diff on last money and money
|
||||
|
||||
var notes ;
|
||||
var moneyInput ;
|
||||
var ddAccount;
|
||||
|
||||
this.defaults = {
|
||||
'open' : false,
|
||||
'notes' : '.note-input',
|
||||
'last_states' : [],
|
||||
'selector_money' : '#accountstate-money',
|
||||
'selector_dd_account' : '#accountstate-id_account',
|
||||
}
|
||||
init();
|
||||
|
||||
function init(){
|
||||
$.extend(app.defaults, o );
|
||||
notes = $(app.defaults.notes);
|
||||
moneyInput = $(app.defaults.selector_money);
|
||||
notes.change(run);
|
||||
moneyInput.change(run);
|
||||
if ( app.defaults.open ){
|
||||
ddAccount = $(app.defaults.selector_dd_account);
|
||||
ddAccount.change(run);
|
||||
}
|
||||
|
||||
run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function run(){
|
||||
calcTotal();
|
||||
calcDiff();
|
||||
calcAccount();
|
||||
calcLastDiff();
|
||||
updateTotal();
|
||||
updateDiff();
|
||||
updateMoney();
|
||||
updateLastMoney();
|
||||
updateLastDiff();
|
||||
updatePrevState();
|
||||
}
|
||||
|
||||
function calcAccount(){
|
||||
if ( app.defaults.open){
|
||||
app.last_money = 0;
|
||||
app.id_account = ddAccount.val();
|
||||
app.last_state = findLastState();
|
||||
if ( app.last_state != null){
|
||||
app.last_money = app.last_state['money'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function calcLastDiff(){
|
||||
app.diff = Math.abs(app.last_money - app.money );
|
||||
|
||||
}
|
||||
function calcDiff(){
|
||||
app.money = 0;
|
||||
app.money = +moneyInput.val();
|
||||
if ( isNaN(money)){
|
||||
app.money = 0;
|
||||
}
|
||||
app.diff = Math.abs(app.total - app.money );
|
||||
|
||||
}
|
||||
function calcTotal(){
|
||||
app.total = 0;
|
||||
notes.each(function(i,e){
|
||||
var value, count;
|
||||
value = +$(e).data('value');
|
||||
count = +$(e).val();
|
||||
if ( isNaN(count))
|
||||
count = 0;
|
||||
app.total += value * count;
|
||||
});
|
||||
}
|
||||
|
||||
function updateTotal(){
|
||||
var money;
|
||||
money = accounting.formatNumber(app.total, 0, " "); // 9 876 543.210
|
||||
$('.notes-total').html(money);
|
||||
}
|
||||
function updateDiff(){
|
||||
var money;
|
||||
money = accounting.formatNumber(app.diff, 0, " "); // 9 876 543.210
|
||||
$('.diff-total').html(money);
|
||||
}
|
||||
function updateMoney(){
|
||||
var money;
|
||||
money = accounting.formatNumber(app.money, 0, " "); // 9 876 543.210
|
||||
$('.money').html(money);
|
||||
}
|
||||
|
||||
function updateLastMoney(){
|
||||
var money;
|
||||
money = accounting.formatNumber(app.last_money, 0, " "); // 9 876 543
|
||||
$('.last-closing-money ').html(money);
|
||||
}
|
||||
|
||||
function updateLastDiff(){
|
||||
var money;
|
||||
money = accounting.formatNumber(app.diff, 0, " "); // 9 876 543.210
|
||||
$('.diff-closing').html(money);
|
||||
}
|
||||
|
||||
function updatePrevState(){
|
||||
|
||||
if ( app.defaults.open){
|
||||
$("#accountstate-prev_state").val( app.last_state == null ? '' : app.last_state.id_account_state);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function findLastState(){
|
||||
var i,result;
|
||||
result = null;
|
||||
for ( var i = 0; i < app.defaults.last_states.length; i++){
|
||||
if ( app.defaults.last_states[i].id_account == app.id_account){
|
||||
result = app.defaults.last_states[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user