add reception account state view and pdf export
This commit is contained in:
@@ -15,7 +15,8 @@ use common\components\RoleDefinition;
|
||||
class DailyListing
|
||||
{
|
||||
|
||||
public $mode = "reception";//reception or admin
|
||||
public $mode = "reception";//reception or admin or accountstate
|
||||
|
||||
/**
|
||||
* string start date , inclusive
|
||||
* */
|
||||
@@ -108,6 +109,25 @@ class DailyListing
|
||||
public $type;
|
||||
|
||||
|
||||
public function readTotalEasy(){
|
||||
$this->readTicketMoney();
|
||||
$this->readProductsMoney();
|
||||
$this->readMoneyMovementMoney();
|
||||
$this->calcTotal();
|
||||
}
|
||||
|
||||
public function readTotalDetailed(){
|
||||
$this->readTickets();
|
||||
$this->readProducts();
|
||||
$this->readMoneyMovements();
|
||||
}
|
||||
public function readTotalMedium(){
|
||||
$this->readProductsByCategory();
|
||||
$this->readProductsByCategoryDetailed();
|
||||
$this->readTicketStas();
|
||||
$this->readMoneyMovementsStats();
|
||||
}
|
||||
|
||||
public function loadFilters($transfer){
|
||||
$this->start = $transfer->start;
|
||||
$this->end = $transfer->end;
|
||||
@@ -119,9 +139,22 @@ class DailyListing
|
||||
$this->timestampEnd = $transfer->timestampEnd;
|
||||
}
|
||||
|
||||
public function loadAccountState($accountState){
|
||||
$this->mode = 'accountstate';
|
||||
$this->start = $accountState->start_date;
|
||||
$this->end = $accountState->created_at;
|
||||
$this->timestampStart = $accountState->start_date;
|
||||
$this->timestampEnd =$accountState->created_at;
|
||||
$this->id_account = $accountState->id_account;
|
||||
$this->id_user = $accountState->id_user;
|
||||
}
|
||||
|
||||
public function isModeAdmin(){
|
||||
return $this->mode == 'admin';
|
||||
}
|
||||
public function isModeAccountState(){
|
||||
return $this->mode == 'accountstate';
|
||||
}
|
||||
|
||||
|
||||
public function calcTotal(){
|
||||
@@ -139,11 +172,15 @@ class DailyListing
|
||||
|
||||
|
||||
public function addAccountConstraint($query){
|
||||
if (!$this->isModeAdmin() || !RoleDefinition::isAdmin() ){
|
||||
|
||||
if ( $this->isModeAccountState() ){
|
||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||
|
||||
}else if (!$this->isModeAdmin() || !RoleDefinition::isAdmin() ){
|
||||
$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||
|
||||
if ( RoleDefinition::isReception() || !$this->isModeAdmin()){
|
||||
if ( RoleDefinition::isReception() || !$this->isModeAdmin()){
|
||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||
}
|
||||
|
||||
|
||||
84
common/components/accountstate/AccountStateWidget.php
Normal file
84
common/components/accountstate/AccountStateWidget.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace common\components\accountstate;
|
||||
use yii\base\Widget;
|
||||
use common\models\AccountState;
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/**
|
||||
* This is the model class for widget display bank notes.
|
||||
*
|
||||
* @property common\models\AccountState $model
|
||||
* */
|
||||
class AccountStateWidget extends Widget{
|
||||
|
||||
public $model;
|
||||
|
||||
|
||||
public function init(){
|
||||
parent::init();
|
||||
}
|
||||
|
||||
public function run(){
|
||||
|
||||
if ($this->model->isTypeOpen() ){
|
||||
$attributes = [
|
||||
[
|
||||
'attribute' =>'account.name',
|
||||
'label' => 'Kassza'
|
||||
],
|
||||
[
|
||||
'attribute' =>'typeName',
|
||||
'label' => 'Típus'
|
||||
],
|
||||
[
|
||||
'attribute' =>'money',
|
||||
'value' => \Yii::$app->formatter->asInteger($this->model->money) ." Ft",
|
||||
],
|
||||
'user.username',
|
||||
[
|
||||
'attribute' => 'created_at',
|
||||
'label' => 'Nyitás ideje'
|
||||
],
|
||||
];
|
||||
}else{
|
||||
|
||||
$attributes = [
|
||||
[
|
||||
'attribute' =>'account.name',
|
||||
'label' => 'Kassza'
|
||||
],
|
||||
[
|
||||
'attribute' =>'typeName',
|
||||
'label' => 'Típus'
|
||||
],
|
||||
[
|
||||
'attribute' =>'money',
|
||||
'value' => \Yii::$app->formatter->asInteger($this->model->money) ." Ft",
|
||||
],
|
||||
'user.username',
|
||||
[
|
||||
'attribute' => 'start_date',
|
||||
'label' => 'Előző nyitás ideje'
|
||||
],
|
||||
[
|
||||
'attribute' => 'created_at',
|
||||
'label' => 'Zárás ideje'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
echo DetailView::widget([
|
||||
'model' => $this->model,
|
||||
'attributes' =>$attributes,
|
||||
]) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
96
common/components/accountstate/BankNotesWidget.php
Normal file
96
common/components/accountstate/BankNotesWidget.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
namespace common\components\accountstate;
|
||||
use yii\base\Widget;
|
||||
use common\models\AccountState;
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
|
||||
/**
|
||||
* This is the model class for widget display bank notes.
|
||||
*
|
||||
* @property common\models\AccountState $model
|
||||
* */
|
||||
class BankNotesWidget extends Widget{
|
||||
|
||||
public $model;
|
||||
|
||||
|
||||
public function init(){
|
||||
parent::init();
|
||||
}
|
||||
|
||||
public function run(){
|
||||
echo $this->generateNotes();
|
||||
}
|
||||
|
||||
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' =>[
|
||||
[
|
||||
'contentOptions' => ['class' => 'note-name'],
|
||||
'value' => 'note',
|
||||
'label' => 'Címlet'
|
||||
],
|
||||
[
|
||||
'value' => 'count',
|
||||
'label' => 'Db'
|
||||
],
|
||||
]
|
||||
]);
|
||||
return $s;
|
||||
}
|
||||
|
||||
}
|
||||
21
common/components/total/TotalBaseWidget.php
Normal file
21
common/components/total/TotalBaseWidget.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
use yii\base\Widget;
|
||||
|
||||
class TotalBaseWidget extends Widget{
|
||||
|
||||
public $dailyListing;
|
||||
|
||||
public $viewPath = '@common/views/total';
|
||||
public $viewFile = 'totaleasy.php';
|
||||
public $view;
|
||||
|
||||
public function init(){
|
||||
$this->view = $this->viewPath . "/" . $this->viewFile;
|
||||
}
|
||||
|
||||
public function run(){
|
||||
echo $this->render($this->view,[ 'model' => $this->dailyListing ]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
|
||||
class TotalDetailedMoneyMovementWidget extends TotalBaseWidget{
|
||||
|
||||
public $viewFile = 'total_detailed_money_movement.php';
|
||||
|
||||
|
||||
}
|
||||
9
common/components/total/TotalDetailedProductsWidget.php
Normal file
9
common/components/total/TotalDetailedProductsWidget.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
|
||||
class TotalDetailedProductsWidget extends TotalBaseWidget{
|
||||
|
||||
public $viewFile = 'total_detailed_product.php';
|
||||
|
||||
|
||||
}
|
||||
9
common/components/total/TotalDetailedTicketsWidget.php
Normal file
9
common/components/total/TotalDetailedTicketsWidget.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
|
||||
class TotalDetailedTicketsWidget extends TotalBaseWidget{
|
||||
|
||||
public $viewFile = 'total_detailed_ticket.php';
|
||||
|
||||
|
||||
}
|
||||
68
common/components/total/TotalDifferenceWidget.php
Normal file
68
common/components/total/TotalDifferenceWidget.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
|
||||
use yii\base\Widget;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/**
|
||||
* Display account state difference information widget
|
||||
*
|
||||
*
|
||||
* @property common\models\AccountState $model
|
||||
*
|
||||
* */
|
||||
class TotalDifferenceWidget extends Widget{
|
||||
|
||||
|
||||
public $model;
|
||||
|
||||
|
||||
public function run(){
|
||||
return $this->generateDifference();
|
||||
}
|
||||
|
||||
protected function generateDifference(){
|
||||
$s = "";
|
||||
if ( $this->model->hasDifferenceToPrevState()){
|
||||
|
||||
$ft = " Ft";
|
||||
$s .= DetailView::widget([
|
||||
'model' => $this->model,
|
||||
'template' =>"<tr><th>{label}</th><td style='text-align: right;'>{value} </td></tr>",
|
||||
'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 előző 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
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
22
common/components/total/TotalEasyWidget.php
Normal file
22
common/components/total/TotalEasyWidget.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
use yii\base\Widget;
|
||||
|
||||
class TotalEasyWidget extends Widget{
|
||||
|
||||
public $dailyListing;
|
||||
|
||||
public $viewPath = '@common/views/total';
|
||||
public $viewFile = 'totaleasy.php';
|
||||
public $view;
|
||||
|
||||
public function init(){
|
||||
$this->view = $this->viewPath . "/" . $this->viewFile;
|
||||
}
|
||||
|
||||
public function run(){
|
||||
echo $this->render($this->view,[ 'model' => $this->dailyListing ]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
|
||||
class TotalMediumMoneyMovementsWidget extends TotalBaseWidget{
|
||||
|
||||
public $viewFile = 'total_medium_money_movement.php';
|
||||
|
||||
|
||||
}
|
||||
9
common/components/total/TotalMediumProductsWidget.php
Normal file
9
common/components/total/TotalMediumProductsWidget.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
|
||||
class TotalMediumProductsWidget extends TotalBaseWidget{
|
||||
|
||||
public $viewFile = 'total_medium_product.php';
|
||||
|
||||
|
||||
}
|
||||
9
common/components/total/TotalMediumTicketsWidget.php
Normal file
9
common/components/total/TotalMediumTicketsWidget.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
|
||||
class TotalMediumTicketsWidget extends TotalBaseWidget{
|
||||
|
||||
public $viewFile = 'total_medium_ticket.php';
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user