diff --git a/common/components/DailyListing.php b/common/components/DailyListing.php
index c3013f6..7fad687 100644
--- a/common/components/DailyListing.php
+++ b/common/components/DailyListing.php
@@ -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 ]);
}
diff --git a/common/components/accountstate/AccountStateWidget.php b/common/components/accountstate/AccountStateWidget.php
new file mode 100644
index 0000000..d0fd53a
--- /dev/null
+++ b/common/components/accountstate/AccountStateWidget.php
@@ -0,0 +1,84 @@
+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,
+ ]) ;
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/common/components/accountstate/BankNotesWidget.php b/common/components/accountstate/BankNotesWidget.php
new file mode 100644
index 0000000..93680bd
--- /dev/null
+++ b/common/components/accountstate/BankNotesWidget.php
@@ -0,0 +1,96 @@
+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;
+ }
+
+}
\ No newline at end of file
diff --git a/common/components/total/TotalBaseWidget.php b/common/components/total/TotalBaseWidget.php
new file mode 100644
index 0000000..eca311b
--- /dev/null
+++ b/common/components/total/TotalBaseWidget.php
@@ -0,0 +1,21 @@
+view = $this->viewPath . "/" . $this->viewFile;
+ }
+
+ public function run(){
+ echo $this->render($this->view,[ 'model' => $this->dailyListing ]);
+ }
+
+}
\ No newline at end of file
diff --git a/common/components/total/TotalDetailedMoneyMovementWidget.php b/common/components/total/TotalDetailedMoneyMovementWidget.php
new file mode 100644
index 0000000..bf37326
--- /dev/null
+++ b/common/components/total/TotalDetailedMoneyMovementWidget.php
@@ -0,0 +1,9 @@
+generateDifference();
+ }
+
+ protected function generateDifference(){
+ $s = "";
+ 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 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;
+ }
+
+
+}
\ No newline at end of file
diff --git a/common/components/total/TotalEasyWidget.php b/common/components/total/TotalEasyWidget.php
new file mode 100644
index 0000000..ca0922a
--- /dev/null
+++ b/common/components/total/TotalEasyWidget.php
@@ -0,0 +1,22 @@
+view = $this->viewPath . "/" . $this->viewFile;
+ }
+
+ public function run(){
+ echo $this->render($this->view,[ 'model' => $this->dailyListing ]);
+ }
+
+
+}
\ No newline at end of file
diff --git a/common/components/total/TotalMediumMoneyMovementsWidget.php b/common/components/total/TotalMediumMoneyMovementsWidget.php
new file mode 100644
index 0000000..b2f99f7
--- /dev/null
+++ b/common/components/total/TotalMediumMoneyMovementsWidget.php
@@ -0,0 +1,9 @@
+type == AccountState::TYPE_OPEN;
+ }
+ public function isTypeClose(){
+ return $this->type == AccountState::TYPE_CLOSE;
+ }
+
public static function banknoteValues()
{
return [
diff --git a/common/models/Transfer.php b/common/models/Transfer.php
index 57c6030..e575a44 100644
--- a/common/models/Transfer.php
+++ b/common/models/Transfer.php
@@ -712,6 +712,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
$query = (new \yii\db\Query());
$query->select(['coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN. ' then transfer.money else -1 * transfer.money end ),0) AS transfer_money']);
$query->from('transfer');
+ $query->innerJoin("account","account.id_account = transfer.id_account");
$query->andWhere(['transfer.id_user' => $idUser ]);
$created_condition = ['and',[ '>=', 'transfer.created_at', $start ] ,[ '<', 'transfer.created_at', $end ] ];
@@ -719,6 +720,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
$query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
+ $query->andWhere(['account.type' => Account::TYPE_ALL]);
return $query->scalar();
}
diff --git a/common/views/account-state/account_state_pdf.php b/common/views/account-state/account_state_pdf.php
new file mode 100644
index 0000000..6c3df5c
--- /dev/null
+++ b/common/views/account-state/account_state_pdf.php
@@ -0,0 +1,102 @@
+type == AccountState::TYPE_OPEN ){
+ $this->title = "Kassza nyitás";
+}else{
+ $this->title = "Kassza zárás";
+}
+
+
+
+?>
+ '>
+
+
+
+
+
= Html::encode($this->title) ?>
+
+ hasDifferenceToPrevState() ){
+ if ( $model->hasMinus()){
+ ?>
+
Negatív különbözet
+
+
Pozitív különbözet
+
+
+
+ $model]);
+ ?>
+
+ hasDifferenceToPrevState() ){
+ ?>
+
Különbözet
+ $model] );
+
+ }
+
+?>
+ type == AccountState::TYPE_CLOSE ){?>
+
+ $details]);?>
+
+
Közepes összesítés
+
Bérletek típus szerint
+ $details]);?>
+
Termékek név szerint
+ $details]);?>
+
Pénzmozgások típus szerint
+ $details]);?>
+
+
Részletek
+ $details]);?>
+ $details]);?>
+ $details]);?>
+
+
Címletek
+ $model]);?>
+
+
+
+
+ Címletek
+ $model]);?>
+
+
+
\ No newline at end of file
diff --git a/common/views/total/total_detailed_money_movement.php b/common/views/total/total_detailed_money_movement.php
new file mode 100644
index 0000000..140fe2f
--- /dev/null
+++ b/common/views/total/total_detailed_money_movement.php
@@ -0,0 +1,41 @@
+Pénzmozgások
+
+
+
+ Dátum
+ Kassza
+ Felhasználó
+ Név
+ Típus
+ Összeg
+
+
+
+ moneyMovements as $p ){?>
+
+
+
+
+
+
+ formatter->asInteger( $p['signed_money'])?> Ft
+
+
+
+
+
+ moneyMovements ) == 0 ) {
+ ?>
+ Nincs találat
+
+
+
+
+ Összesen: formatter->asInteger( $model->moneyMovementMoneis); ?> Ft
+
+
+
+
\ No newline at end of file
diff --git a/common/views/total/total_detailed_product.php b/common/views/total/total_detailed_product.php
new file mode 100644
index 0000000..85806c6
--- /dev/null
+++ b/common/views/total/total_detailed_product.php
@@ -0,0 +1,51 @@
+
+ Termék eladások
+
+
+
+ Kiadva
+ Fizetve
+ Kassza
+ Felhasználó
+ Kategória
+ Termék
+ Egység ár
+ Mennyiség
+ Összeg
+
+
+
+ products as $p ){?>
+
+
+
+
+
+
+
+ Ft
+ Db
+ formatter->asInteger( $p['product_money'])?> FT
+
+
+
+
+
+ products ) == 0 ) {
+ ?>
+ Nincs találat
+
+
+
+
+ Összesen: formatter->asInteger( $model->productMoney); ?> Ft
+
+
+
\ No newline at end of file
diff --git a/common/views/total/total_detailed_ticket.php b/common/views/total/total_detailed_ticket.php
new file mode 100644
index 0000000..cf58189
--- /dev/null
+++ b/common/views/total/total_detailed_ticket.php
@@ -0,0 +1,46 @@
+Bérletek
+
+
+
+ Kiadva
+ Fizetve
+ Kassza
+ Felhasználó
+ Bérlet típus
+ Egység ár
+ Mennyiség
+ Összeg
+
+
+
+ tickets as $t ){?>
+
+
+
+
+
+
+ Ft
+ Db
+ formatter->asInteger( $t['ticket_money'])?> FT
+
+
+
+
+
+ tickets ) == 0 ) {
+ ?>
+ Nincs találat
+
+
+
+
+ Összesen: formatter->asInteger( $model->ticketMoney); ?> Ft
+
+
+
+
+
+
+
+ Pénzmozgás típus
+ Mennyiség
+ Összeg
+
+
+
+ moneyMovementsByType as $mmStat ) {
+ ?>
+
+
+ Db
+ formatter->asInteger( $mmStat['money_movement_money'])?> FT
+
+
+
+
+
+
+ Összesen: formatter->asInteger( $model->moneyMovementMoneis); ?> Ft
+
+
+
diff --git a/common/views/total/total_medium_product.php b/common/views/total/total_medium_product.php
new file mode 100644
index 0000000..f6f14bf
--- /dev/null
+++ b/common/views/total/total_medium_product.php
@@ -0,0 +1,45 @@
+productsByCategory ['categories'] as $categoryHolder ) {
+
+ $products = $categoryHolder ['products'];
+ ?>
+
+
+
+
+
+ Termék
+ Mennyiség
+ Összeg
+
+
+
+
+
+
+
+ Db
+ formatter->asInteger( $p['product_money'])?> FT
+
+
+
+
+
+
+ formatter->asInteger( $categoryHolder['total'])?> FT
+
+
+
+
+
+
+ Összesen:
+ formatter->asInteger( $model->productsByCategory ['total']);
+ ?> Ft
+
+
\ No newline at end of file
diff --git a/common/views/total/total_medium_ticket.php b/common/views/total/total_medium_ticket.php
new file mode 100644
index 0000000..ddc00ca
--- /dev/null
+++ b/common/views/total/total_medium_ticket.php
@@ -0,0 +1,27 @@
+
+
+
+ Bérlet típus
+ Mennyiség
+ Összeg
+
+
+
+ ticketStats as $ticketStat ) {
+ ?>
+
+
+ Db
+ formatter->asInteger( $ticketStat['ticket_money'])?> FT
+
+
+
+
+
+
+
+ Összesen: formatter->asInteger( $model->ticketMoney); ?> Ft
+
+
+
\ No newline at end of file
diff --git a/common/views/total/totaleasy.php b/common/views/total/totaleasy.php
new file mode 100644
index 0000000..276f18e
--- /dev/null
+++ b/common/views/total/totaleasy.php
@@ -0,0 +1,46 @@
+
+
+render('_list_pdf_head',[ 'searchModel' =>$model, 'label' => 'Napi bevételek - Egyszerű','type' =>'easy']);
+?>
+
+Egyszerű összesítés
+ output) ){
+
+// $pdfUrl = Url::current([ Html::getInputName($model, 'output') => 'pdf']);
+// echo Html::a("Teljes PDF letöltése", $pdfUrl,['class' => 'btn btn-primary btn-all' ]);
+
+// $pdfUrl = Url::current([ Html::getInputName($model, 'output') => 'pdf', Html::getInputName($model, 'outputView') => 'easy']);
+// echo Html::a("Egyszerű összesítő Pdf", $pdfUrl,['class' => 'btn btn-primary' ]);
+// }
+
+
+?>
+ Bruttó
+
+
+
+ Bérletek
+ formatter->asInteger( $model->ticketMoney)?> FT
+
+
+ Termékek
+ formatter->asInteger( $model->productMoney)?> FT
+
+
+ Pénzmozgások
+ formatter->asInteger( $model->moneyMovementMoneis)?> FT
+
+
+ Végösszeg bruttó
+ formatter->asInteger( $model->total)?> FT
+
+
+
+
diff --git a/frontend/components/AccountStateBanknoteCountWidget.php b/frontend/components/AccountStateBanknoteCountWidget.php
index d824430..b4c05fd 100644
--- a/frontend/components/AccountStateBanknoteCountWidget.php
+++ b/frontend/components/AccountStateBanknoteCountWidget.php
@@ -9,7 +9,14 @@ use yii\grid\GridView;
use yii\base\Object;
use yii\data\ArrayDataProvider;
use yii\helpers\Url;
+use common\components\total\TotalDifferenceWidget;
+/**
+ * Display account state widget
+ *
+ * @property common\models\AccountState $model the account state object
+ * @property int $index the current index in the list
+ * */
class AccountStateBanknoteCountWidget extends Widget{
public $model;
@@ -37,53 +44,27 @@ class AccountStateBanknoteCountWidget extends Widget{
$s .= $this->generateInfoRow();
- $s .= $this->generateNotes();
-
+// $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 .= "Különbözet ";
+ $s .= TotalDifferenceWidget::widget(['model' => $this->model]);
}
+
$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]), [
+ $s .= Html::a( Html::tag("span","",['class' =>'glyphicon glyphicon-download-alt']) ." Pdf", Url::to([ 'view', 'id' =>$this->model->id_account_state, 'output' =>'pdf']) ,['class' => 'btn btn-primary btn-pdf','style' =>'margin-bottom: 12px; margin-right: 6px;']);
+
+ $s .= Html::a(' Részletek', Url::toRoute(['view','id' =>$this->model->id_account_state]), [
+ 'title' => 'Részletek',
+ 'class' => 'btn btn-success',
+ 'style' =>'margin-bottom: 12px; margin-right: 6px;'
+ ]);
+ $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',
diff --git a/frontend/components/FrontendMenuStructure.php b/frontend/components/FrontendMenuStructure.php
index 485ebbf..0449231 100644
--- a/frontend/components/FrontendMenuStructure.php
+++ b/frontend/components/FrontendMenuStructure.php
@@ -19,10 +19,12 @@ class FrontendMenuStructure{
public $startDate;//start date
public $tomorrowDate;//tomorrow date
+ public $yesterDay;//yesterday date
public function __construct(){
$this->menuItems = [];
+ $this->yesterDay = \Yii::$app->formatter->asDatetime( strtotime('yesterday UTC') );
$this->start = \Yii::$app->formatter->asDatetime( strtotime('today UTC') );
$this->tomorrow = Yii::$app->formatter->asDatetime( strtotime('tomorrow UTC') );
$this->startDate = Yii::$app->formatter->asDate( strtotime('today UTC') );
@@ -66,7 +68,7 @@ class FrontendMenuStructure{
$items = [
['label' => Yii::t('frontend/account-state','Default account'), 'url' => ['/account/select'] ],
- ['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index'] ],
+ ['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index' ,'AccountstateSearch[id_account]' => Account::readDefault(), 'AccountstateSearch[start]' => $this->yesterDay] ],
['label' => Yii::t('frontend/account-state','Open account state'), 'url' => ['/account-state/open'] ],
['label' => Yii::t('frontend/account-state','Close account state'), 'url' => ['/account-state/close'] ],
diff --git a/frontend/controllers/AccountStateController.php b/frontend/controllers/AccountStateController.php
index 9f1c596..54d67f2 100644
--- a/frontend/controllers/AccountStateController.php
+++ b/frontend/controllers/AccountStateController.php
@@ -9,179 +9,231 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
+use common\components\DailyListing;
+use common\models\User;
/**
* AccountStateController implements the CRUD actions for AccountState model.
*/
-class AccountStateController extends Controller
-{
- public function behaviors()
- {
- return [
- 'access' => [
- 'class' => \yii\filters\AccessControl::className(),
- 'only' => [ 'index','open','close'],
- 'rules' => [
- // allow authenticated users
- [
- 'allow' => true,
- 'roles' => ['@'],
- ],
- // everything else is denied
- ],
- ],
- ];
- }
-
- /**
- * 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,
- ]);
- }
-
-
- /**
- * 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();
+class AccountStateController extends Controller {
+ public function behaviors() {
+ return [
+ 'access' => [
+ 'class' => \yii\filters\AccessControl::className (),
+ 'only' => [
+ 'index',
+ 'open',
+ 'close',
+ 'view'
+ ],
+ 'rules' => [
+ // allow authenticated users
+ [
+ 'allow' => true,
+ 'roles' => [
+ '@'
+ ]
+ ]
+ ]
+ ]
+ // everything else is denied
+
+
+ ];
+ }
+
+ /**
+ * Lists all AccountState models.
+ *
+ * @return mixed
+ */
+ public function actionIndex() {
+ $searchModel = new AccountstateSearch ();
+
+ $searchModel->accounts = Account::read ();
+ $searchModel->users = User::read ();
+
+ $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
+
+ return $this->render ( 'index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider
+ ] );
+ }
+
+ /**
+ * 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;
- $model->id_account = Account::readDefault();
- 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()
- {
- $lastStates = AccountState::readLastForUser(AccountState::TYPE_OPEN );
- $lastStates = AccountState::modelsToArray($lastStates);
- $model = new AccountState();
- $model->type = AccountState::TYPE_CLOSE;
- $model->id_user = Yii::$app->user->id;
- $model->id_account = Account::readDefault();
- 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,
- 'lastStates' => $lastStates,
- ]);
- }
- }
-
-
-
-
-
- /**
- * 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.');
- }
- }
- /**
- * 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();
- \Yii::$app->session->setFlash( 'success','Kassza művelet törölve' );
- return $this->redirect(Yii::$app->request->referrer);
- }
- /**
- * Displays a single AccountState model.
- * @param integer $id
- * @return mixed
-
- public function actionView($id)
- {
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
- }
- */
+ $model->id_user = Yii::$app->user->id;
+ $model->id_account = Account::readDefault ();
+ 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() {
+ $lastStates = AccountState::readLastForUser ( AccountState::TYPE_OPEN );
+ $lastStates = AccountState::modelsToArray ( $lastStates );
+ $model = new AccountState ();
+ $model->type = AccountState::TYPE_CLOSE;
+ $model->id_user = Yii::$app->user->id;
+ $model->id_account = Account::readDefault ();
+ 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,
+ 'lastStates' => $lastStates
+ ] );
+ }
+ }
+
+ /**
+ * 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.' );
+ }
+ }
+ /**
+ * 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 ();
+ \Yii::$app->session->setFlash ( 'success', 'Kassza művelet törölve' );
+ return $this->redirect ( Yii::$app->request->referrer );
+ }
+ /*
+ * Displays a single AccountState model.
+ * @param integer $id
+ * $var common\models\AccountState $accountState
+ * @return mixed
+ */
+ public function actionView($id) {
+ $accountState = $this->findModel ( $id );
+ $output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
+ $details = null;
+ if ($accountState->isTypeClose ()) {
+
+ $prev;
+ if ($accountState->type == AccountState::TYPE_CLOSE) {
+ if (isset ( $accountState->prev_state )) {
+ $prev = AccountState::findOne ( $accountState->prev_state );
+ }
+ if (isset ( $prev )) {
+ $accountState->start_date = $prev->created_at;
+ }
+ }
+ $details = new DailyListing ();
+ $details->loadAccountState ( $accountState );
+
+ $details->readTotalEasy ();
+ $details->readTotalDetailed ();
+ $details->readTotalMedium ();
+ }
+
+ if ($output == 'pdf') {
+ $user = User::findOne(\Yii::$app->user->id);
+ $mpdf=new \mPDF('utf-8', 'A4-L');
+ $mpdf->useSubstitutions=false;
+ $mpdf->simpleTables = true;
+ $mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
+ $mpdf->setFooter('{PAGENO} / {nb}');
+ $mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [
+ 'model' => $accountState,
+ 'details' => $details
+ ]));
+ $type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
+ $dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
+ $fn= $type .$dt.".pdf";
+ $mpdf->Output($fn, 'D');
+
+ } else {
+
+ return $this->render ( 'view', [
+ 'model' => $accountState,
+ 'details' => $details
+ ] );
+ }
+ }
}
diff --git a/frontend/models/AccountstateSearch.php b/frontend/models/AccountstateSearch.php
index d18c225..e690752 100644
--- a/frontend/models/AccountstateSearch.php
+++ b/frontend/models/AccountstateSearch.php
@@ -12,12 +12,25 @@ use common\models\AccountState;
*/
class AccountstateSearch extends AccountState
{
+
+ public $start;
+ public $end;
+
+ public $timestampStart;
+ public $timestampEnd;
+
+
+ public $accounts;
+ public $users;
/**
* @inheritdoc
*/
public function rules()
{
- return [
+ return [
+ [[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
+ [[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
+ [ [ 'id_account','id_user' ,'type' ] , 'integer'],
];
}
@@ -54,9 +67,19 @@ class AccountstateSearch extends AccountState
return $dataProvider;
}
+
$query->innerJoinWith('account');
$query->innerJoinWith('account.userAccountAssignments');
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
+ $query->andFilterWhere([
+ 'account_state.id_user' => $this->id_user,
+ 'account_state.type' => $this->type,
+ 'account_state.id_account' => $this->id_account,
+ ]);
+
+ $query->andFilterWhere([ '>=', 'account_state.created_at', $this->timestampStart ] );
+ $query->andFilterWhere([ '<', 'account_state.created_at', $this->timestampEnd ] );
+
$query->orderBy( 'created_at desc' );
$query->limit = 20;
diff --git a/frontend/views/account-state/_search.php b/frontend/views/account-state/_search.php
index c68771e..5516097 100644
--- a/frontend/views/account-state/_search.php
+++ b/frontend/views/account-state/_search.php
@@ -2,12 +2,19 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
+use kartik\widgets\DateTimePicker;
+use frontend\components\HtmlHelper;
+use common\models\AccountState;
/* @var $this yii\web\View */
/* @var $model frontend\models\AccountstateSearch */
/* @var $form yii\widgets\ActiveForm */
?>
-
+'Mind']+ HtmlHelper::mkAccountOptions( $model->accounts );
+$userOptions = ['' => 'Mind'] + HtmlHelper::mkOptions($model->users,'id','username');
+$typeOptions = ['' => 'Mind'] + AccountState::types();
+?>
'get',
]); ?>
- = $form->field($model, 'id_account_state') ?>
- = $form->field($model, 'id_account') ?>
+
+
+ = $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
+
+
+ = $form->field($model, 'id_user')->dropDownList($userOptions) ?>
+
+
+ = $form->field($model, 'type')->dropDownList($typeOptions) ?>
+
+
+
+
+
+ = $form->field($model, 'start')->widget(DateTimePicker::classname(), [
+ 'pluginOptions' => [
+ 'autoclose'=>true,
+ 'format' => 'yyyy.mm.dd hh:ii'
+ ]
+ ])->label('Időszak kezdete') ?>
+
+
+ = $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
+ 'pluginOptions' => [
+ 'autoclose'=>true,
+ 'format' => 'yyyy.mm.dd hh:ii'
+ ]
+ ])->label("Időszak vége") ?>
+
+
- = $form->field($model, 'type') ?>
-
- = $form->field($model, 'money') ?>
-
- = $form->field($model, 'banknote_5_ft') ?>
-
- field($model, 'banknote_10_ft') ?>
-
- field($model, 'banknote_20_ft') ?>
-
- field($model, 'banknote_50_ft') ?>
-
- field($model, 'banknote_100_ft') ?>
-
- field($model, 'banknote_200_ft') ?>
-
- field($model, 'banknote_500_ft') ?>
-
- field($model, 'banknote_1000_ft') ?>
-
- field($model, 'banknote_2000_ft') ?>
-
- field($model, 'banknote_5000_ft') ?>
-
- field($model, 'banknote_10000_ft') ?>
-
- field($model, 'banknote_20000_ft') ?>
-
- field($model, 'id_user') ?>
-
- field($model, 'created_at') ?>
-
- field($model, 'updated_at') ?>
= Html::submitButton(Yii::t('frontend/account-state', 'Search'), ['class' => 'btn btn-primary']) ?>
- = Html::resetButton(Yii::t('frontend/account-state', 'Reset'), ['class' => 'btn btn-default']) ?>
diff --git a/frontend/views/account-state/index.php b/frontend/views/account-state/index.php
index 3c102ad..b3e6c74 100644
--- a/frontend/views/account-state/index.php
+++ b/frontend/views/account-state/index.php
@@ -23,7 +23,7 @@ $this->params['breadcrumbs'][] = $this->title;
= Html::encode($this->title) ?>
- render('_search', ['model' => $searchModel]); ?>
+ render('_search', ['model' => $searchModel]); ?>
= Html::a(Yii::t('frontend/account-state', 'Open Account State'), ['open'], ['class' => 'btn btn-success']) ?>
diff --git a/frontend/views/account-state/view.php b/frontend/views/account-state/view.php
index f56074c..aeaab98 100644
--- a/frontend/views/account-state/view.php
+++ b/frontend/views/account-state/view.php
@@ -2,52 +2,117 @@
use yii\helpers\Html;
use yii\widgets\DetailView;
+use common\components\total\TotalEasyWidget;
+use common\components\total\TotalDetailedProductsWidget;
+use common\components\total\TotalDetailedTicketsWidget;
+use common\components\total\TotalDetailedMoneyMovementWidget;
+use common\components\accountstate\BankNotesWidget;
+use common\components\total\TotalMediumTicketsWidget;
+use common\components\total\TotalMediumProductsWidget;
+use common\components\total\TotalMediumMoneyMovementsWidget;
+use common\components\total\TotalDifferenceWidget;
+use yii\base\Widget;
+use common\models\AccountState;
+use yii\helpers\Url;
+use common\components\accountstate\AccountStateWidget;
/* @var $this yii\web\View */
/* @var $model common\models\AccountState */
-
-$this->title = $model->id_account_state;
+if ( $model ->type == AccountState::TYPE_OPEN ){
+ $this->title = "Kassza nyitás";
+}else{
+ $this->title = "Kassza zárás";
+}
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account-state', 'Account States'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
+
+
= Html::encode($this->title) ?>
+
+ hasDifferenceToPrevState() ){
+ if ( $model->hasMinus()){
+ ?>
+
Negatív különbözet
+
+
Pozitív különbözet
+
+ $model]) ?>
+
+ 'glyphicon glyphicon-download-alt'])." Pdf", Url::current(['output' =>'pdf']) ,['class' => 'btn btn-primary btn-pdf']);
+ ?>
+
+ hasDifferenceToPrevState() ){
+ ?>
+
Különbözet
+ $model] );
+
+ }
+
+?>
+ type == AccountState::TYPE_CLOSE ){?>
+
-
- = 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',
- ],
- ]) ?>
-
+
+
- = 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',
- ],
- ]) ?>
+
+
+
+ $details]);?>
+
+
+
Közepes összesítés
+ Bérletek típus szerint
+ $details]);?>
+ Termékek név szerint
+ $details]);?>
+ Pénzmozgások típus szerint
+ $details]);?>
+
+
+
Részletek
+ $details]);?>
+ $details]);?>
+ $details]);?>
+
+
+
Címletek
+ $model]);?>
+
+
+
+
Címletek
+ $model]);?>
+
+
+
\ No newline at end of file