add account state changes

This commit is contained in:
2016-01-08 19:09:42 +01:00
parent 0e023e3f3e
commit 0084526094
10 changed files with 414 additions and 58 deletions

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

View File

@@ -7,4 +7,6 @@ return [
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
'notify_mail' => ['rocho02@gmail.com' ],
'mail_account_state_open' => true,
];

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