add display money to account state close, delete ticket on customer tickets
This commit is contained in:
@@ -12,6 +12,8 @@ use common\models\Account;
|
||||
use common\components\DailyListing;
|
||||
use common\models\User;
|
||||
use common\components\accountstate\AccountStateMail;
|
||||
use common\models\Transfer;
|
||||
use common\components\Helper;
|
||||
|
||||
/**
|
||||
* AccountStateController implements the CRUD actions for AccountState model.
|
||||
@@ -111,6 +113,17 @@ class AccountStateController extends Controller {
|
||||
$model->type = AccountState::TYPE_CLOSE;
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
$model->id_account = Account::readDefault ();
|
||||
|
||||
$lastCassaState = AccountState::readLast(null,null, Account::readDefault());
|
||||
|
||||
|
||||
|
||||
|
||||
if ( Helper::isAccountStateClosePreloadMoney()){
|
||||
$model->money = $this->readCassaClose();
|
||||
}
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
|
||||
|
||||
@@ -128,11 +141,22 @@ class AccountStateController extends Controller {
|
||||
return $this->render ( 'close', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'lastStates' => $lastStates
|
||||
'lastStates' => $lastStates ,
|
||||
'lastCassaState' => $lastCassaState,
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
protected function readCassaClose(){
|
||||
$total = 0;
|
||||
$cassaOpen = AccountState::readLast(AccountState::TYPE_OPEN,null, Account::readDefault());
|
||||
if ( isset($cassaOpen )){
|
||||
$total += $cassaOpen->money;
|
||||
}
|
||||
$total += Transfer::readPaid($cassaOpen->created_at, date('Y-d-m h:i:s'), \Yii::$app->user->id);
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the AccountState model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
|
||||
@@ -126,5 +126,54 @@ class TicketController extends FrontendController
|
||||
'receptionForm' => $receptionForm,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Transfer model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$ticket = $this->findModel($id);
|
||||
$transfer = Transfer::find()->andWhere(['transfer.type' => Transfer::TYPE_TICKET])
|
||||
->andWhere(['transfer.id_object' => $ticket->id_ticket])
|
||||
->one();
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction();
|
||||
try {
|
||||
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
if ( $transfer->delete() ){
|
||||
\Yii::$app->session->setFlash( 'success','Bérlet törölve' );
|
||||
$transaction->commit();
|
||||
}else{
|
||||
throw new \Exception("Failed to save");
|
||||
}
|
||||
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback();
|
||||
\Yii::$app->session->setFlash( 'danger','Bérlet törlése nem sikerült' );
|
||||
}
|
||||
|
||||
|
||||
return $this->redirect(Yii::$app->request->referrer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Ticket model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Ticket the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Ticket::findOne($id)) !== null) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use common\models\Customer;
|
||||
use common\models\Ticket;
|
||||
use common\models\Account;
|
||||
use common\models\CardSearch;
|
||||
use common\models\AccountState;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
@@ -21,6 +22,7 @@ class ReceptionForm extends Model
|
||||
public $tickets;
|
||||
public $defaultAccount;
|
||||
public $cardSearchModel;
|
||||
public $lastCassaState;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@@ -58,10 +60,33 @@ class ReceptionForm extends Model
|
||||
$this->defaultAccount = Account::findOne($defaultAccount);
|
||||
}
|
||||
|
||||
$this->readLastCassaState();
|
||||
$this->cardSearchModel = new CardSearch();
|
||||
|
||||
}
|
||||
|
||||
public function readLastCassaState(){
|
||||
$a = Account::readDefault();
|
||||
if ( isset($a)){
|
||||
$this->lastCassaState = AccountState::find()->andWhere(['account_state.id_account' => $a])
|
||||
->andWhere(['account_state.id_user' => \Yii::$app->user->id] )
|
||||
->orderBy(['account_state.created_at' => SORT_DESC])
|
||||
->limit(1)
|
||||
->one();
|
||||
}
|
||||
}
|
||||
|
||||
public function hasCassa(){
|
||||
return isset($this->lastCassaState) ;
|
||||
}
|
||||
|
||||
public function isCassaOpen(){
|
||||
return ( isset($this->lastCassaState) && $this->lastCassaState->isTypeOpen());
|
||||
}
|
||||
public function isCassaClose(){
|
||||
return ( isset($this->lastCassaState) && $this->lastCassaState->isTypeClose());
|
||||
}
|
||||
|
||||
public function getDefaultAccountName(){
|
||||
$result = "";
|
||||
if ( $this->defaultAccount ){
|
||||
|
||||
@@ -7,6 +7,7 @@ use frontend\components\HtmlHelper;
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
/* @var $lastCassaState common\models\AccountState */
|
||||
?>
|
||||
|
||||
|
||||
@@ -57,7 +58,6 @@ use frontend\components\HtmlHelper;
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton( Yii::t('frontend/account-state', 'Close account'), ['class' => 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,7 @@ $this->registerJs ( 'new AccountState( '. json_encode($options).');' );
|
||||
<?= $this->render('_form_close', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'lastCassaState' => $lastCassaState,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -8,11 +8,25 @@ use frontend\components\ReceptionTicketWidget;
|
||||
use frontend\components\ReceptionCustomerWidget;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\helpers\Html;
|
||||
|
||||
/** @var $model frontend\models\ReceptionForm */
|
||||
?>
|
||||
<?php
|
||||
$alertClass = "info";
|
||||
$cassaMessage = "Nyitva";
|
||||
if ( $model->isCassaClose() ){
|
||||
$alertClass = "danger";
|
||||
$cassaMessage = "Zárva";
|
||||
}else if ( !$model->hasCassa() ){
|
||||
$alertClass = "danger";
|
||||
$cassaMessage = "Nincs kassza kiválasztva";
|
||||
}
|
||||
?>
|
||||
<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<div class="alert alert-info">
|
||||
Aktuális kassza: <?php echo $model->getDefaultAccountName();?>
|
||||
<div class="alert alert-<?php echo $alertClass;?>">
|
||||
Aktuális kassza: <?php echo $model->getDefaultAccountName();?> -
|
||||
<?php echo $cassaMessage;?>
|
||||
</div>
|
||||
</div>
|
||||
<?php $form = ActiveForm::begin([
|
||||
|
||||
@@ -32,6 +32,10 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'name',
|
||||
'money',
|
||||
'created_at:datetime',
|
||||
[
|
||||
'attribute' => 'comment',
|
||||
'format' => 'html'
|
||||
],
|
||||
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view}'
|
||||
|
||||
@@ -59,11 +59,9 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
*/
|
||||
'price_brutto',
|
||||
'created_at:datetime',
|
||||
/*
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' =>'{view} {update}',
|
||||
'template' =>'{delete}',
|
||||
],
|
||||
*/
|
||||
],
|
||||
]); ?>
|
||||
|
||||
|
||||
@@ -3,9 +3,11 @@ use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\ListView;
|
||||
use yii\base\Widget;
|
||||
use yii\helpers\Url;
|
||||
use common\components\Helper;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel common\models\TransferSearch */
|
||||
/* @var $searchModel common\models\TransferListSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t ( 'frontend/transfer', 'Daily transfers' );
|
||||
@@ -82,10 +84,31 @@ td.name{
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Végösszeg</th>
|
||||
<td class="money"><span style='border-bottom: 1px solid black'><?php echo $searchModel->total?> FT</span></td>
|
||||
<td class="money"><span style='border-bottom: 1px solid black'><?php echo \Yii::$app->formatter->asInteger($searchModel->total)?> FT</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if ( $searchModel->isModeReception() && Helper::isAccountStateClosePreloadMoney()){?>
|
||||
<h2>Aktuális záró összeg</h2>
|
||||
<table class="table table-bordered table-striped table-summary">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Kasszanyitás</th>
|
||||
<td class="money"><span style=' '><?php echo isset($searchModel->cassaOpen) ? \Yii::$app->formatter->asInteger( $searchModel->cassaOpen->money ) : ""?> FT</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Végösszeg</th>
|
||||
<td class="money"><span style=' '><?php echo \Yii::$app->formatter->asInteger($searchModel->total)?> FT</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Kasszában lévő összeg</th>
|
||||
<td class="money"><span style='border-bottom: 1px solid black'><?php echo \Yii::$app->formatter->asInteger( $searchModel->totalWithCassa ) ?> FT</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php echo Html::a("Ugrás kassza zárásra",Url::toRoute([ 'account-state/close', 'money' => $searchModel->totalWithCassa ]), ['class' =>'btn btn-primary'])?>
|
||||
<?php }?>
|
||||
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="medium">
|
||||
<h2>Közepes összesítés</h2>
|
||||
@@ -351,6 +374,7 @@ td.name{
|
||||
<th>Név</th>
|
||||
<th>Típus</th>
|
||||
<th>Összeg</th>
|
||||
<th>Megjegyzés</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -362,6 +386,7 @@ td.name{
|
||||
<td><?php echo $p['money_movement_name'] ?></td>
|
||||
<td><?php echo $p['money_movement_type_name'] ?></td>
|
||||
<td class='money'><?php echo $p['signed_money']?> Ft</td>
|
||||
<td><?php echo $p['money_movement_comment'] ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
Reference in New Issue
Block a user