add account state changes
This commit is contained in:
parent
0e023e3f3e
commit
0084526094
@ -10,6 +10,7 @@ use yii\web\NotFoundHttpException;
|
|||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
use common\models\User;
|
use common\models\User;
|
||||||
|
use common\components\DailyListing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountStateController implements the CRUD actions for AccountState model.
|
* AccountStateController implements the CRUD actions for AccountState model.
|
||||||
@ -17,6 +18,24 @@ use common\models\User;
|
|||||||
class AccountStateController extends \backend\controllers\BackendController
|
class AccountStateController extends \backend\controllers\BackendController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function behaviors()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'access' => [
|
||||||
|
'class' => \yii\filters\AccessControl::className(),
|
||||||
|
'rules' => [
|
||||||
|
// allow authenticated users
|
||||||
|
[
|
||||||
|
'actions' => ['create','index','view','update','delete'],
|
||||||
|
'allow' => true,
|
||||||
|
'roles' => ['admin','employee','reception'],
|
||||||
|
],
|
||||||
|
// everything else is denied
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all AccountState models.
|
* Lists all AccountState models.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@ -30,7 +49,6 @@ class AccountStateController extends \backend\controllers\BackendController
|
|||||||
$users = User::read();
|
$users = User::read();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $this->render('index', [
|
return $this->render('index', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
@ -44,12 +62,65 @@ class AccountStateController extends \backend\controllers\BackendController
|
|||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function actionView($id)
|
/*
|
||||||
{
|
* Displays a single AccountState model.
|
||||||
|
* @param integer $id
|
||||||
|
* $var common\models\AccountState $accountState
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionView($id) {
|
||||||
|
echo "view";
|
||||||
|
$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}');
|
||||||
|
|
||||||
|
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||||
|
$mpdf->WriteHTML($stylesheet,1);
|
||||||
|
|
||||||
|
|
||||||
|
$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', [
|
return $this->render ( 'view', [
|
||||||
'model' => $this->findModel($id),
|
'model' => $accountState,
|
||||||
|
'details' => $details
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new AccountState model.
|
* Creates a new AccountState model.
|
||||||
@ -88,6 +159,37 @@ class AccountStateController extends \backend\controllers\BackendController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
$model = $this->findModel ( $id );
|
||||||
|
|
||||||
|
$delete = true;
|
||||||
|
if ( $model->isTypeOpen() ){
|
||||||
|
$closeStates = AccountState::find()->andWhere( ['prev_state' => $model->id_account_state] )->all();
|
||||||
|
|
||||||
|
if ( count($closeStates) > 0){
|
||||||
|
$delete = false;
|
||||||
|
\Yii::$app->session->setFlash('error', ['Nem lehet törölni a nyitást, mert van kapcsolódó zárás!']);
|
||||||
|
throw new \Exception('Nem lehet törölni a nyitást, mert van kapcsolódó zárás!');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $delete == true ){
|
||||||
|
$model->delete();
|
||||||
|
\Yii::$app->session->setFlash ( 'success', 'Kassza művelet törölve' );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->redirect ( ["index"] );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an existing AccountState model.
|
* Deletes an existing AccountState model.
|
||||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
|
|||||||
@ -117,6 +117,10 @@ class TransferController extends \backend\controllers\BackendController
|
|||||||
$mpdf->simpleTables = true;
|
$mpdf->simpleTables = true;
|
||||||
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||||
$mpdf->setFooter('{PAGENO} / {nb}');
|
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||||
|
|
||||||
|
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||||
|
$mpdf->WriteHTML($stylesheet,1);
|
||||||
|
|
||||||
$mpdf->WriteHTML($this->renderPartial($ov, [
|
$mpdf->WriteHTML($this->renderPartial($ov, [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
]));
|
]));
|
||||||
@ -184,6 +188,8 @@ class TransferController extends \backend\controllers\BackendController
|
|||||||
|
|
||||||
|
|
||||||
$mpdf=new \mPDF('utf-8', 'A4-L');
|
$mpdf=new \mPDF('utf-8', 'A4-L');
|
||||||
|
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||||
|
$mpdf->WriteHTML($stylesheet,1);
|
||||||
$mpdf->WriteHTML($this->renderPartial('_result_sale', [
|
$mpdf->WriteHTML($this->renderPartial('_result_sale', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
]));
|
]));
|
||||||
|
|||||||
@ -17,6 +17,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<?php echo $this->render('_search', ['model' => $searchModel,'accounts' => $accounts,'users' => $users,]); ?>
|
<?php echo $this->render('_search', ['model' => $searchModel,'accounts' => $accounts,'users' => $users,]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php /*echo GridView::widget([
|
<?php /*echo GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
'columns' => [
|
'columns' => [
|
||||||
|
|||||||
@ -2,55 +2,117 @@
|
|||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\DetailView;
|
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 $this yii\web\View */
|
||||||
/* @var $model common\models\AccountState */
|
/* @var $model common\models\AccountState */
|
||||||
|
if ( $model ->type == AccountState::TYPE_OPEN ){
|
||||||
$this->title = $model->id_account_state;
|
$this->title = "Kassza nyitás";
|
||||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/account-state', 'Account States'), 'url' => ['index']];
|
}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;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.btn-pdf{
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.money{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="account-state-view">
|
<div class="account-state-view">
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
<p>
|
<?php
|
||||||
<?= Html::a(Yii::t('backend/account-state', 'Update'), ['update', 'id' => $model->id_account_state], ['class' => 'btn btn-primary']) ?>
|
if ( $model->hasDifferenceToPrevState() ){
|
||||||
<?= Html::a(Yii::t('backend/account-state', 'Delete'), ['delete', 'id' => $model->id_account_state], [
|
if ( $model->hasMinus()){
|
||||||
'class' => 'btn btn-danger',
|
?>
|
||||||
'data' => [
|
<div class="alert alert-danger" role="alert">Negatív különbözet</div>
|
||||||
'confirm' => Yii::t('backend/account-state', 'Are you sure you want to delete this item?'),
|
<?php
|
||||||
'method' => 'post',
|
}else{
|
||||||
],
|
?>
|
||||||
]) ?>
|
<div class="alert alert-success" role="alert">Pozitív különbözet</div>
|
||||||
</p>
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php echo AccountStateWidget::widget(['model' =>$model]) ?>
|
||||||
|
|
||||||
<?= DetailView::widget([
|
<?php
|
||||||
'model' => $model,
|
echo Html::a( Html::tag("span","",['class' =>'glyphicon glyphicon-download-alt'])." Pdf", Url::current(['output' =>'pdf']) ,['class' => 'btn btn-primary btn-pdf']);
|
||||||
'attributes' => [
|
?>
|
||||||
'id_account_state',
|
|
||||||
'id_account',
|
<?php if ( $model->hasDifferenceToPrevState() ){
|
||||||
'type',
|
?>
|
||||||
'money',
|
<h2>Különbözet</h2>
|
||||||
'banknote_5_ft',
|
<?php
|
||||||
'banknote_10_ft',
|
echo TotalDifferenceWidget::widget(['model' => $model] );
|
||||||
'banknote_20_ft',
|
|
||||||
'banknote_50_ft',
|
}
|
||||||
'banknote_100_ft',
|
|
||||||
'banknote_200_ft',
|
?>
|
||||||
'banknote_500_ft',
|
<?php if ( $model ->type == AccountState::TYPE_CLOSE ){?>
|
||||||
'banknote_1000_ft',
|
<div>
|
||||||
'banknote_2000_ft',
|
|
||||||
'banknote_5000_ft',
|
<!-- Nav tabs -->
|
||||||
'banknote_10000_ft',
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
'banknote_20000_ft',
|
<li role="presentation" class="active"><a href="#easy"
|
||||||
'id_user',
|
aria-controls="easy" role="tab" data-toggle="tab">Egyszerű összesítő</a></li>
|
||||||
'created_at',
|
<li role="presentation"><a href="#medium" aria-controls="medium"
|
||||||
'updated_at',
|
role="tab" data-toggle="tab">Közepes összesítő</a></li>
|
||||||
'comment',
|
<li role="presentation"><a href="#detailed" aria-controls="detailed"
|
||||||
'prev_state',
|
role="tab" data-toggle="tab">Részletes összesítő</a></li>
|
||||||
'prev_money',
|
<li role="presentation" class=""><a href="#banknotes"
|
||||||
],
|
aria-controls="banknotes" role="tab" data-toggle="tab">Címletek</a></li>
|
||||||
]) ?>
|
</ul>
|
||||||
|
|
||||||
|
<!-- Tab panes -->
|
||||||
|
<div class="tab-content">
|
||||||
|
<div role="tabpanel" class="tab-pane active" id="easy">
|
||||||
|
<?php echo TotalEasyWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane " id="medium">
|
||||||
|
<h2>Közepes összesítés</h2>
|
||||||
|
<h3>Bérletek típus szerint</h3>
|
||||||
|
<?php echo TotalMediumTicketsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<h3>Termékek név szerint</h3>
|
||||||
|
<?php echo TotalMediumProductsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<h3>Pénzmozgások típus szerint</h3>
|
||||||
|
<?php echo TotalMediumMoneyMovementsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane " id="detailed">
|
||||||
|
<h2>Részletek</h2>
|
||||||
|
<?php echo TotalDetailedTicketsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<?php echo TotalDetailedProductsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<?php echo TotalDetailedMoneyMovementWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane " id="banknotes">
|
||||||
|
<h2>Címletek</h2>
|
||||||
|
<?php echo BankNotesWidget::widget(['model' => $model]);?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php }else{?>
|
||||||
|
<h2>Címletek</h2>
|
||||||
|
<?php echo BankNotesWidget::widget(['model' => $model]);?>
|
||||||
|
<?php }?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -53,14 +53,7 @@ $items = $adminMenu->run();
|
|||||||
<?= Breadcrumbs::widget([
|
<?= Breadcrumbs::widget([
|
||||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
|
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
|
||||||
]) ?>
|
]) ?>
|
||||||
<?php //echo Alert::widget() ?>
|
<?php echo Alert::widget() ?>
|
||||||
<?php
|
|
||||||
echo AlertBlock::widget([
|
|
||||||
'useSessionFlash' => true,
|
|
||||||
'type' => AlertBlock::TYPE_GROWL,
|
|
||||||
'delay' => '1'
|
|
||||||
]);
|
|
||||||
?>
|
|
||||||
<?= $content ?>
|
<?= $content ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use yii\widgets\Breadcrumbs;
|
use yii\widgets\Breadcrumbs;
|
||||||
use dmstr\widgets\Alert;
|
use dmstr\widgets\Alert;
|
||||||
|
use kartik\widgets\AlertBlock;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
@ -15,7 +16,13 @@ use dmstr\widgets\Alert;
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<?= Alert::widget() ?>
|
<?php
|
||||||
|
echo AlertBlock::widget([
|
||||||
|
'useSessionFlash' => true,
|
||||||
|
'type' => AlertBlock::TYPE_GROWL,
|
||||||
|
'delay' => '1'
|
||||||
|
]);
|
||||||
|
?>
|
||||||
<?= $content ?>
|
<?= $content ?>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
67
common/components/accountstate/AccountStateMail.php
Normal file
67
common/components/accountstate/AccountStateMail.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
namespace common\components\accountstate;
|
||||||
|
|
||||||
|
|
||||||
|
use yii\base\Object;
|
||||||
|
use common\models\User;
|
||||||
|
use common\models\Account;
|
||||||
|
use common\models\AccountState;
|
||||||
|
use common\components\DailyListing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property common\models\AccountState $model
|
||||||
|
* */
|
||||||
|
class AccountStateMail extends Object {
|
||||||
|
|
||||||
|
|
||||||
|
public $model;
|
||||||
|
|
||||||
|
|
||||||
|
public function init(){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function sednMail(){
|
||||||
|
|
||||||
|
$details = null;
|
||||||
|
if ($this->model ->isTypeClose ()) {
|
||||||
|
|
||||||
|
$prev;
|
||||||
|
if ($this->model ->type == AccountState::TYPE_CLOSE) {
|
||||||
|
if (isset ( $accountState->prev_state )) {
|
||||||
|
$prev = AccountState::findOne ( $accountState->prev_state );
|
||||||
|
}
|
||||||
|
if (isset ( $prev )) {
|
||||||
|
$this->model ->start_date = $prev->created_at;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$details = new DailyListing();
|
||||||
|
$details->loadAccountState ( $this->model );
|
||||||
|
|
||||||
|
$details->readTotalEasy ();
|
||||||
|
$details->readTotalDetailed ();
|
||||||
|
$details->readTotalMedium ();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = User::findOne($this->model->id_user);
|
||||||
|
$account = Account::findOne($this->model->id_account);
|
||||||
|
$subject = $this->model->isTypeOpen() ? "Kassza nyitás " : "Kassza zárás";
|
||||||
|
$subject .= " - " . $user->username ." - ". $account->name;
|
||||||
|
|
||||||
|
$mail = \Yii::$app->mailer->compose('account_state', [
|
||||||
|
'model' => $this->model,
|
||||||
|
'details' => $details
|
||||||
|
]);
|
||||||
|
$mail->setFrom('noreplay@fitnessadmin.hu')
|
||||||
|
->setTo( \Yii::$app->params['notify_mail'] )
|
||||||
|
->setSubject($subject )
|
||||||
|
->send();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,4 +7,6 @@ return [
|
|||||||
'company' => 'movar',//gyor
|
'company' => 'movar',//gyor
|
||||||
'company_name' => "Freimann Kft.",
|
'company_name' => "Freimann Kft.",
|
||||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
|
'notify_mail' => ['rocho02@gmail.com' ],
|
||||||
|
'mail_account_state_open' => true,
|
||||||
];
|
];
|
||||||
|
|||||||
87
common/mail/account_state.php
Normal file
87
common/mail/account_state.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
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 common\models\AccountState;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
use common\components\accountstate\AccountStateWidget;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\AccountState */
|
||||||
|
if ( $model ->type == AccountState::TYPE_OPEN ){
|
||||||
|
$this->title = "Kassza nyitás";
|
||||||
|
}else{
|
||||||
|
$this->title = "Kassza zárás";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
table{
|
||||||
|
|
||||||
|
}
|
||||||
|
th,td{
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
td.money{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="account-state-view">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ( $model->hasDifferenceToPrevState() ){
|
||||||
|
if ( $model->hasMinus()){
|
||||||
|
?>
|
||||||
|
<div class="alert alert-danger" role="alert">Negatív különbözet</div>
|
||||||
|
<?php
|
||||||
|
}else{
|
||||||
|
?>
|
||||||
|
<div class="alert alert-success" role="alert">Pozitív különbözet</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php echo AccountStateWidget::widget(['model' =>$model]) ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php if ( $model->hasDifferenceToPrevState() ){
|
||||||
|
?>
|
||||||
|
<h2>Különbözet</h2>
|
||||||
|
<?php
|
||||||
|
echo TotalDifferenceWidget::widget(['model' => $model] );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ( $model ->type == AccountState::TYPE_CLOSE ){?>
|
||||||
|
|
||||||
|
<?php echo TotalEasyWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<h2>Közepes összesítés</h2>
|
||||||
|
<h3>Bérletek típus szerint</h3>
|
||||||
|
<?php echo TotalMediumTicketsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<h3>Termékek név szerint</h3>
|
||||||
|
<?php echo TotalMediumProductsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<h3>Pénzmozgások típus szerint</h3>
|
||||||
|
<?php echo TotalMediumMoneyMovementsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<?php }else{?>
|
||||||
|
<h2>Címletek</h2>
|
||||||
|
<?php echo BankNotesWidget::widget(['model' => $model]);?>
|
||||||
|
<?php }?>
|
||||||
|
|
||||||
|
</div>
|
||||||
@ -11,6 +11,7 @@ use yii\filters\VerbFilter;
|
|||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
use common\components\DailyListing;
|
use common\components\DailyListing;
|
||||||
use common\models\User;
|
use common\models\User;
|
||||||
|
use common\components\accountstate\AccountStateMail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountStateController implements the CRUD actions for AccountState model.
|
* AccountStateController implements the CRUD actions for AccountState model.
|
||||||
@ -77,6 +78,12 @@ class AccountStateController extends Controller {
|
|||||||
$model->id_account = Account::readDefault ();
|
$model->id_account = Account::readDefault ();
|
||||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||||
|
|
||||||
|
|
||||||
|
$mail = new AccountStateMail(['model' => $model]);
|
||||||
|
$mail->sednMail();
|
||||||
|
|
||||||
|
|
||||||
return $this->redirect ( [
|
return $this->redirect ( [
|
||||||
'index'
|
'index'
|
||||||
] );
|
] );
|
||||||
@ -105,6 +112,11 @@ class AccountStateController extends Controller {
|
|||||||
$model->id_user = Yii::$app->user->id;
|
$model->id_user = Yii::$app->user->id;
|
||||||
$model->id_account = Account::readDefault ();
|
$model->id_account = Account::readDefault ();
|
||||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||||
|
|
||||||
|
|
||||||
|
$mail = new AccountStateMail(['model' => $model]);
|
||||||
|
$mail->sednMail();
|
||||||
|
|
||||||
return $this->redirect ( [
|
return $this->redirect ( [
|
||||||
'index'
|
'index'
|
||||||
] );
|
] );
|
||||||
@ -179,8 +191,20 @@ class AccountStateController extends Controller {
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function actionDelete($id) {
|
public function actionDelete($id) {
|
||||||
$this->findModel ( $id )->delete ();
|
$model = $this->findModel ( $id );
|
||||||
|
$delete = true;
|
||||||
|
if ( $model->isTypeOpen() ){
|
||||||
|
$closeStates = AccountState::find()->andWhere(['prev_state' => $model->id_account_state])->all();
|
||||||
|
if ( count($closeStates) > 0){
|
||||||
|
// throw new \Exception("Nem lehet törölni a nyitást, mert van kapcsolódó zárás!");
|
||||||
|
\Yii::$app->session->setFlash ( 'error', "Nem lehet törölni a nyitást, mert van kapcsolódó zárás!" );
|
||||||
|
$delete = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( $delete == true){
|
||||||
|
$model->delete();
|
||||||
\Yii::$app->session->setFlash ( 'success', 'Kassza művelet törölve' );
|
\Yii::$app->session->setFlash ( 'success', 'Kassza művelet törölve' );
|
||||||
|
}
|
||||||
return $this->redirect ( Yii::$app->request->referrer );
|
return $this->redirect ( Yii::$app->request->referrer );
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -219,6 +243,11 @@ class AccountStateController extends Controller {
|
|||||||
$mpdf->simpleTables = true;
|
$mpdf->simpleTables = true;
|
||||||
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||||
$mpdf->setFooter('{PAGENO} / {nb}');
|
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||||
|
|
||||||
|
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||||
|
$mpdf->WriteHTML($stylesheet,1);
|
||||||
|
|
||||||
|
|
||||||
$mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [
|
$mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [
|
||||||
'model' => $accountState,
|
'model' => $accountState,
|
||||||
'details' => $details
|
'details' => $details
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user