add changes to account state

This commit is contained in:
2015-10-19 07:48:46 +02:00
parent b04cbda645
commit 9145f21371
50 changed files with 2139 additions and 27 deletions

View 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;
}
}

View File

@@ -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'] ],
]
];
}
}

View File

@@ -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;
}
}