model->hasDifferenceToPrevState()){
if ( $this->model->hasPlus()){
$panelStyleClas = 'panel-success';
}else if ( $this->model->hasMinus() ){
$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();
if ( $this->model->hasDifferenceToPrevState()){
$ft = " Ft";
$s .= DetailView::widget([
'model' => $this->model,
'template' =>"
| {label} | {value} |
",
'attributes' => [
[
'label' => "Előző nyitás ideje",
'value' => $this->model->prevObject ? \Yii::$app->formatter->asDatetime( $this->model->prevObject->created_at) : "-",
],
[
'label' => "Előzőleg nyitott",
'value' => $this->model->prevObject ? $this->model->user->username : "-",
],
[
'label' => "Előző nyitás összege",
'value' => $this->model->prev_money.$ft
],
[
'label' => "Bevételek összesen utolsó nyitás óta",
'value' => $this->model->collection_money .$ft
],
[
'label' => "Zárás összege",
'value' => $this->model->money.$ft
],
[
'label' => "Várt összeg",
'value' => $this->model->expected.$ft
],
[
'label' => "Különbözet",
'value' => $this->model->signedDiff.$ft
],
]
]);
}
$s .= $this->generateComment();
$s .= Html::beginTag("div", ['class' => 'row', 'style' => 'margin-top: 6px;']);
$s .= Html::beginTag("div", ['class' => 'col-md-12 text-right']);
$s .= Html::a('Törlés', Url::toRoute(['delete','id' =>$this->model->id_account_state]), [
'title' => \Yii::t('yii', 'Delete'),
'data-confirm' =>\Yii::t('yii', 'Are you sure to delete this item?'),
'data-method' => 'post',
'class' => 'btn btn-danger',
'style' =>'margin-bottom: 12px;'
]);
$s .= Html::endTag("div");//end col
$s .= Html::endTag("div");//end row
$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;
}
}