add changes to account state
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user