Finish version/v.0.0.22
This commit is contained in:
commit
2511cff8ff
@ -1,3 +1,12 @@
|
||||
-0.0.22
|
||||
- fix product barcode unique on admin site
|
||||
- When checking ticket, use status = Active
|
||||
- force cassa open, if trying to enter prodcut/ticket sell page
|
||||
- force select default account
|
||||
-0.0.21
|
||||
- account state fix account on reception
|
||||
- reception user - tickets > delete ticket
|
||||
- show current account
|
||||
-0.0.20
|
||||
- account state email with pdf
|
||||
- login email
|
||||
|
||||
@ -9,6 +9,7 @@ use common\models\Account;
|
||||
|
||||
use common\models\MoneyMovement;
|
||||
use common\components\RoleDefinition;
|
||||
use common\models\AccountState;
|
||||
/**
|
||||
* TransferListSearch represents the model behind the search form about `common\models\Transfer`.
|
||||
*/
|
||||
@ -108,7 +109,15 @@ class DailyListing
|
||||
public $id_user;
|
||||
public $type;
|
||||
|
||||
|
||||
public $totalWithCassa;
|
||||
|
||||
public $cassaOpen;
|
||||
|
||||
public $showWithCassaOpen = false;// if easy total should be displayed with cassa open money
|
||||
|
||||
public $accountState; //the cassa object for we load the data
|
||||
|
||||
|
||||
public function readTotalEasy(){
|
||||
$this->readTicketMoney();
|
||||
$this->readProductsMoney();
|
||||
@ -141,6 +150,7 @@ class DailyListing
|
||||
|
||||
public function loadAccountState($accountState){
|
||||
$this->mode = 'accountstate';
|
||||
$this->accountState = $accountState;
|
||||
$this->start = $accountState->start_date;
|
||||
$this->end = $accountState->created_at;
|
||||
$this->timestampStart = $accountState->start_date;
|
||||
@ -149,13 +159,26 @@ class DailyListing
|
||||
$this->id_user = $accountState->id_user;
|
||||
}
|
||||
|
||||
public function readModeAccountState(){
|
||||
$this->readTotalEasy ();
|
||||
$this->readTotalDetailed ();
|
||||
$this->readTotalMedium ();
|
||||
|
||||
$this->readCassaOpen();
|
||||
$this->calcTotalWithCassaOpen();
|
||||
|
||||
$this->showWithCassaOpen = true;
|
||||
}
|
||||
|
||||
public function isModeAdmin(){
|
||||
return $this->mode == 'admin';
|
||||
}
|
||||
public function isModeAccountState(){
|
||||
return $this->mode == 'accountstate';
|
||||
}
|
||||
|
||||
public function isModeReception(){
|
||||
return $this->mode == 'reception';
|
||||
}
|
||||
|
||||
public function calcTotal(){
|
||||
$this->total = 0;
|
||||
@ -170,6 +193,22 @@ class DailyListing
|
||||
$this->totalNetto += $this->moneyMovementMoneis;
|
||||
}
|
||||
|
||||
protected function readCassaOpen(){
|
||||
if ( isset($this->accountState) && $this->accountState->isTypeClose() && isset($this->accountState->prev_state) ){
|
||||
$this->cassaOpen = AccountState::findOne(['id_account_state' => $this->accountState->prev_state]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function calcTotalWithCassaOpen(){
|
||||
$this->totalWithCassa = 0;
|
||||
$this->totalWithCassa += $this->total;
|
||||
if ( isset($this->cassaOpen ) ){
|
||||
$this->totalWithCassa += $this->cassaOpen->money;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function addAccountConstraint($query){
|
||||
|
||||
@ -513,7 +552,7 @@ class DailyListing
|
||||
|
||||
public function readMoneyMovements(){
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select([ 'user.username as user_name','account.name as account_name', 'transfer.direction as transfer_direction' ,'money_movement.type as money_movement_type', 'transfer.money AS money_movement_money', 'money_movement.name as money_movement_name','transfer.created_at as money_movement_created_at', ]);
|
||||
$query->select([ 'user.username as user_name','account.name as account_name', 'transfer.direction as transfer_direction' ,'money_movement.type as money_movement_type', 'transfer.money AS money_movement_money', 'money_movement.name as money_movement_name','transfer.created_at as money_movement_created_at', 'money_movement.comment as money_movement_comment' ]);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]);
|
||||
$query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object");
|
||||
|
||||
@ -161,6 +161,9 @@ class Helper {
|
||||
public static function isProductVisibilityAccount() {
|
||||
return \Yii::$app->params ['product_visiblity'] == 'account';
|
||||
}
|
||||
public static function isAccountStateClosePreloadMoney() {
|
||||
return \Yii::$app->params ['account_state_close_preload_money'] == true;
|
||||
}
|
||||
public static function getRealUserIp() {
|
||||
$client = @$_SERVER ['HTTP_CLIENT_IP'];
|
||||
$forward = @$_SERVER ['HTTP_X_FORWARDED_FOR'];
|
||||
|
||||
@ -42,9 +42,11 @@ class AccountStateMail extends Object {
|
||||
$this->details = new DailyListing();
|
||||
$this->details->loadAccountState ( $this->model );
|
||||
|
||||
$this->details->readTotalEasy ();
|
||||
$this->details->readTotalDetailed ();
|
||||
$this->details->readTotalMedium ();
|
||||
$this->details->readModeAccountState();
|
||||
|
||||
// $this->details->readTotalEasy ();
|
||||
// $this->details->readTotalDetailed ();
|
||||
// $this->details->readTotalMedium ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +63,7 @@ class AccountStateMail extends Object {
|
||||
|
||||
$this->attachPdf();
|
||||
|
||||
$this->message->setFrom('noreplay@fitnessadmin.hu')
|
||||
$this->message->setFrom(\Yii::$app->params['infoEmail'])
|
||||
->setTo( \Yii::$app->params['notify_mail'] )
|
||||
->setSubject($subject )
|
||||
->send();
|
||||
|
||||
9
common/components/total/TotalCassaOpenInfoWidget.php
Normal file
9
common/components/total/TotalCassaOpenInfoWidget.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace common\components\total;
|
||||
|
||||
class TotalCassaOpenInfoWidget extends TotalBaseWidget{
|
||||
|
||||
public $viewFile = 'total_cassa_open.php';
|
||||
|
||||
|
||||
}
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'supportEmail' => 'rocho02@gmail.com',
|
||||
'infoEmail' => 'info@rocho-net.hu',
|
||||
'user.passwordResetTokenExpire' => 3600,
|
||||
'version' => 'v0.0.20',
|
||||
'version' => 'v0.0.22',
|
||||
'company' => 'movar',//gyor
|
||||
'company_name' => "Freimann Kft.",
|
||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||
@ -12,5 +12,6 @@ return [
|
||||
'mail_account_state_open' => true,
|
||||
'login_reception_email' => true, //if reception login should send email
|
||||
'login_admin_email' => true, //if admin login should send email
|
||||
'account_state_close_preload_money' => 'true',//preload money wnen show account state close page
|
||||
|
||||
];
|
||||
|
||||
@ -13,6 +13,7 @@ use common\components\total\TotalDifferenceWidget;
|
||||
use common\models\AccountState;
|
||||
use yii\helpers\Url;
|
||||
use common\components\accountstate\AccountStateWidget;
|
||||
use common\components\total\TotalCassaOpenInfoWidget;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
@ -72,6 +73,8 @@ if ( $model ->type == AccountState::TYPE_OPEN ){
|
||||
<?php if ( $model ->type == AccountState::TYPE_CLOSE ){?>
|
||||
|
||||
<?php echo TotalEasyWidget::widget(['dailyListing' => $details]);?>
|
||||
|
||||
<?php echo TotalCassaOpenInfoWidget::widget(['dailyListing' => $details]);?>
|
||||
<h2>Közepes összesítés</h2>
|
||||
<h3>Bérletek típus szerint</h3>
|
||||
<?php echo TotalMediumTicketsWidget::widget(['dailyListing' => $details]);?>
|
||||
|
||||
@ -34,7 +34,7 @@ return [
|
||||
'Id Account' => 'Kassza',
|
||||
'Id Account State' => 'Kassza művelet',
|
||||
'Id User' => 'Felhasználó',
|
||||
'Money' => 'Összeg',
|
||||
'Money' => 'Kasszában lévő összeg',
|
||||
'Type' => 'Típus',
|
||||
'Updated At' => 'Módosítás ideje',
|
||||
];
|
||||
|
||||
@ -152,11 +152,29 @@ class Account extends \yii\db\ActiveRecord
|
||||
|
||||
}
|
||||
|
||||
/** read id_transfer from session (default account )
|
||||
*
|
||||
* @return int id_transfer
|
||||
* */
|
||||
public static function readDefault( ){
|
||||
$session = Yii::$app->session;
|
||||
$result = $session->get('id_account');
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* read default transfer object
|
||||
* return the default account or null, if not found
|
||||
* @return common\models\Account
|
||||
* */
|
||||
public static function readDefaultObject( ){
|
||||
$account = null;
|
||||
$id_account = self::readDefault();
|
||||
if ( isset($id_account)){
|
||||
$account = Account::findOne($id_account);
|
||||
}
|
||||
return $account;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\db\QueryBuilder;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
|
||||
/**
|
||||
* This is the model class for table "account_state".
|
||||
@ -38,6 +38,17 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
||||
|
||||
public $start_date;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
// public function behaviors()
|
||||
// {
|
||||
// return [[
|
||||
// 'class' => TimestampBehavior::className(),
|
||||
// 'value' => function(){ return date('Y-m-d H:i' ); }
|
||||
// ] ];
|
||||
// }
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@ -52,11 +63,10 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_account','money' ], 'required'],
|
||||
[['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' ], 'integer'],
|
||||
[['money' ], 'required'],
|
||||
[['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' ], 'integer'],
|
||||
[['comment' ], 'string' ,'max' => 255],
|
||||
[['prev_state' ], 'integer'],
|
||||
[['id_account'] , 'validatePrevState'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -183,6 +193,8 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
||||
* Read last accountstates
|
||||
* @param $type int the type of accountstate to load
|
||||
* @param $user $id of user to load the account
|
||||
* @return common\models\AccountState
|
||||
*
|
||||
* */
|
||||
public static function readLast($type, $user = null,$account = null){
|
||||
$result = null;
|
||||
@ -191,9 +203,13 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
||||
if ( isset($type)){
|
||||
$query->andWhere(['account_state.type' => $type]);
|
||||
}
|
||||
if ( $account ){
|
||||
if ( isset( $account ) ){
|
||||
$query->andWhere(["account_state.id_account" => $account ]);
|
||||
}
|
||||
|
||||
if ( isset( $user ) ){
|
||||
$query->andWhere(["account_state.id_user" => $user ]);
|
||||
}
|
||||
|
||||
$query->limit(1);
|
||||
|
||||
|
||||
@ -46,14 +46,17 @@ class Product extends \common\models\BaseFitnessActiveRecord {
|
||||
[['id_product_category', 'id_account', 'name'], 'required'],
|
||||
[['id_product_category', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'],
|
||||
[['product_number', 'barcode'], 'string', 'max' => 20],
|
||||
[['product_number', 'barcode'], 'filter', 'filter' => 'trim', 'skipOnArray' => true],
|
||||
[['name'], 'string', 'max' => 128],
|
||||
[['description'], 'string', 'max' => 255],
|
||||
[['product_number'], 'unique' ],
|
||||
[['barcode'], 'unique' ],
|
||||
// [['product_number'], 'unique' ],
|
||||
// [['barcode'], 'unique' ],
|
||||
// a1 and a2 need to be unique together, only a1 will receive error message
|
||||
// ['a1', 'unique', 'targetAttribute' => ['a1', 'a2']]
|
||||
[['barcode','product_number'], 'filter', 'filter' => function($value){return Helper::fixAsciiChars($value);}],
|
||||
['barcode', 'unique', 'targetAttribute' => ['id_account', 'barcode']],
|
||||
['product_number', 'unique', 'targetAttribute' => ['id_account', 'product_number']],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -165,10 +165,11 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
$query = Ticket::find();
|
||||
$today = date('Y-m-d');
|
||||
|
||||
$query->andWhere(['id_card' => $card->id_card]);
|
||||
$query->andWhere( 'start <= :today' ,[ 'today' => $today] );
|
||||
$query->andWhere( 'end >= :today' ,[ 'today' => $today] );
|
||||
$query->orderBy([ "created_at" =>SORT_DESC] );
|
||||
$query->andWhere(['ticket.id_card' => $card->id_card]);
|
||||
$query->andWhere( 'ticket.start <= :today' ,[ 'today' => $today] );
|
||||
$query->andWhere( 'ticket.end >= :today' ,[ 'today' => $today] );
|
||||
$query->andWhere( 'ticket.status = :status' ,[ 'status' => Ticket::STATUS_ACTIVE] );
|
||||
$query->orderBy([ "ticket.created_at" =>SORT_DESC] );
|
||||
$result = $query->all();
|
||||
|
||||
return $result;
|
||||
|
||||
@ -14,6 +14,7 @@ use common\models\Account;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\MoneyMovement;
|
||||
use common\components\RoleDefinition;
|
||||
use common\components\Helper;
|
||||
/**
|
||||
* TransferListSearch represents the model behind the search form about `common\models\Transfer`.
|
||||
*/
|
||||
@ -22,30 +23,28 @@ class TransferListSearch extends Transfer
|
||||
|
||||
public $mode = "reception";//reception or admin
|
||||
|
||||
/**start date string*/
|
||||
public $start;
|
||||
/**end date string*/
|
||||
public $end;
|
||||
|
||||
/**start date*/
|
||||
public $timestampStart;
|
||||
/** end date*/
|
||||
public $timestampEnd;
|
||||
|
||||
|
||||
|
||||
// public $totalsCreatedAt = ['total' => 0, 'accounts' =>[] ];
|
||||
// public $totalsCreatedAtNotPaid= ['total' => 0, 'accounts' =>[]];
|
||||
// public $totalsCreatedAtPaid= ['total' => 0, 'accounts' =>[]];
|
||||
// public $totalsPaidAt= ['total' => 0, 'accounts' =>[]];
|
||||
// public $totalsPaidAtNotCreatedAt= ['total' => 0, 'accounts' =>[]];
|
||||
|
||||
/**if include cassa open*/
|
||||
public $includeCassaOpen = false;
|
||||
/**total with cassa open*/
|
||||
public $totalWithCassa;
|
||||
/**last cassa open*/
|
||||
public $cassaOpen;
|
||||
|
||||
public $totals;
|
||||
|
||||
/**The accounts*/
|
||||
public $accounts;
|
||||
|
||||
/**types*/
|
||||
public $types;
|
||||
|
||||
/**users*/
|
||||
public $users;
|
||||
|
||||
|
||||
/**
|
||||
* all money gained with ticket sell
|
||||
* */
|
||||
@ -124,6 +123,9 @@ class TransferListSearch extends Transfer
|
||||
public function isModeAdmin(){
|
||||
return $this->mode == 'admin';
|
||||
}
|
||||
public function isModeReception(){
|
||||
return $this->mode == 'reception';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
@ -149,11 +151,20 @@ class TransferListSearch extends Transfer
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->readTicketMoney();
|
||||
$this->readProductsMoney();
|
||||
$this->readMoneyMovementMoney();
|
||||
$this->calcTotal();
|
||||
|
||||
if ( $this->isModeReception()){
|
||||
if ( Helper::isAccountStateClosePreloadMoney()){
|
||||
$this->readCassaOpen();
|
||||
$this->calcTotalWithCassaOpen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->readProductsByCategory();
|
||||
$this->readProductsByCategoryDetailed();
|
||||
$this->readTicketStas();
|
||||
@ -179,12 +190,24 @@ class TransferListSearch extends Transfer
|
||||
|
||||
}
|
||||
|
||||
protected function readCassaOpen(){
|
||||
$this->cassaOpen = AccountState::readLast(AccountState::TYPE_OPEN,null,Account::readDefault());
|
||||
}
|
||||
|
||||
protected function calcTotal(){
|
||||
$this->total = 0;
|
||||
$this->total += $this->ticketMoney;
|
||||
$this->total += $this->productMoney;
|
||||
$this->total += $this->moneyMovementMoneis;
|
||||
}
|
||||
protected function calcTotalWithCassaOpen(){
|
||||
$this->totalWithCassa = 0;
|
||||
$this->totalWithCassa += $this->total;
|
||||
if ( isset($this->cassaOpen ) ){
|
||||
$this->totalWithCassa += $this->cassaOpen->money;
|
||||
}
|
||||
|
||||
}
|
||||
protected function calcTotalNetto(){
|
||||
$this->totalNetto = 0;
|
||||
$this->totalNetto += $this->ticketMoney;
|
||||
@ -437,7 +460,7 @@ class TransferListSearch extends Transfer
|
||||
|
||||
protected function readMoneyMovements(){
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select([ 'user.username as user_name','account.name as account_name', 'transfer.direction as transfer_direction' ,'money_movement.type as money_movement_type', 'transfer.money AS money_movement_money', 'money_movement.name as money_movement_name','transfer.created_at as money_movement_created_at', ]);
|
||||
$query->select([ 'user.username as user_name','account.name as account_name', 'transfer.direction as transfer_direction' ,'money_movement.type as money_movement_type', 'transfer.money AS money_movement_money', 'money_movement.name as money_movement_name','transfer.created_at as money_movement_created_at', 'money_movement.comment as money_movement_comment' ]);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]);
|
||||
$query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object");
|
||||
|
||||
@ -62,6 +62,9 @@ if ( $model ->type == AccountState::TYPE_OPEN ){
|
||||
<?php
|
||||
echo AccountStateWidget::widget(['model' => $model]);
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php if ( $model->hasDifferenceToPrevState() ){
|
||||
?>
|
||||
|
||||
31
common/views/total/total_cassa_open.php
Normal file
31
common/views/total/total_cassa_open.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
use common\components\DailyListing;
|
||||
/** @var $model common\components\DailyListing */
|
||||
?>
|
||||
<?php if ( $model->showWithCassaOpen && isset($model->cassaOpen) ){?>
|
||||
<h2>Aktuális záró összeg</h2>
|
||||
<table class="table table-bordered table-striped table-summary">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Kasszanyitás </th>
|
||||
<td ><span style=' '><?php echo ( $model->cassaOpen->user->username ) ?> </span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Kasszanyitás ideje</th>
|
||||
<td ><span style=' '><?php echo ( $model->cassaOpen->created_at ) ?> </span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Kasszanyitás összege</th>
|
||||
<td class="money"><span style=' '><?php echo isset($model->cassaOpen) ? \Yii::$app->formatter->asInteger( $model->cassaOpen->money ) : ""?> FT</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Végösszeg</th>
|
||||
<td class="money"><span style=' '><?php echo \Yii::$app->formatter->asInteger($model->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( $model->totalWithCassa ) ?> FT</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php }?>
|
||||
@ -8,6 +8,7 @@
|
||||
<th>Név</th>
|
||||
<th>Típus</th>
|
||||
<th>Összeg</th>
|
||||
<th>Megjegyzés</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -19,6 +20,7 @@
|
||||
<td><?php echo $p['money_movement_name'] ?></td>
|
||||
<td><?php echo $p['money_movement_type_name'] ?></td>
|
||||
<td class='money'><?php echo \Yii::$app->formatter->asInteger( $p['signed_money'])?> Ft</td>
|
||||
<td><?php echo $p['money_movement_comment'] ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
37
frontend/components/CassaOpenBehavior.php
Normal file
37
frontend/components/CassaOpenBehavior.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace frontend\components;
|
||||
|
||||
use yii\base\Behavior;
|
||||
use yii\web\Controller;
|
||||
use common\models\Account;
|
||||
use common\models\AccountState;
|
||||
|
||||
class CassaOpenBehavior extends Behavior
|
||||
{
|
||||
// ...
|
||||
|
||||
public function events()
|
||||
{
|
||||
return [
|
||||
Controller::EVENT_BEFORE_ACTION => 'validateCassaOpen',
|
||||
];
|
||||
}
|
||||
|
||||
public function validateCassaOpen($event){
|
||||
|
||||
$cassaOpen = AccountState::readLast(null, null, Account::readDefault() );
|
||||
|
||||
if ( !isset($cassaOpen) ){
|
||||
return $this->redirectToCassaOpen($event);
|
||||
}else if ( !$cassaOpen->isTypeOpen() ){
|
||||
return $this->redirectToCassaOpen($event);
|
||||
}
|
||||
}
|
||||
|
||||
protected function redirectToCassaOpen($event ) {
|
||||
\Yii::$app->session->setFlash ( 'error', 'Nem nyitottál kasszát!');
|
||||
$this->owner->redirect([ 'account-state/open' ]);
|
||||
$event->isValid = false;
|
||||
$event->handled = true;
|
||||
}
|
||||
}
|
||||
31
frontend/components/DefaultAccountBehavior.php
Normal file
31
frontend/components/DefaultAccountBehavior.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace frontend\components;
|
||||
|
||||
use yii\base\Behavior;
|
||||
use yii\web\Controller;
|
||||
use common\models\Account;
|
||||
|
||||
class DefaultAccountBehavior extends Behavior
|
||||
{
|
||||
// ...
|
||||
|
||||
public function events()
|
||||
{
|
||||
return [
|
||||
Controller::EVENT_BEFORE_ACTION => 'validateDefaultAccount',
|
||||
];
|
||||
}
|
||||
|
||||
public function validateDefaultAccount($event){
|
||||
echo "deafult";
|
||||
|
||||
$account = Account::readDefault();
|
||||
if ( !isset($account) ){
|
||||
$this->owner->redirect([ 'account/select' ]);
|
||||
\Yii::$app->session->setFlash ( 'error', 'Válassz kasszát!!');
|
||||
$event->isValid = false;
|
||||
$event->handled = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,7 @@ class FrontendMenuStructure{
|
||||
|
||||
if ( $isadmin || Yii::$app->user->can('reception.transfers') ){
|
||||
$items[] = ['label' => Yii::t('frontend/transfer','Transfers'), 'url' => ['/transfer/index', 'TransferSearch[id_user]' =>\Yii::$app->user->id, 'TransferSearch[id_account]' => Account::readDefault(), 'TransferSearch[start]' => $this->start, 'TransferSearch[end]' => $this->tomorrow ] ];
|
||||
$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
||||
//$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
||||
}
|
||||
|
||||
$items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ];
|
||||
|
||||
@ -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.
|
||||
@ -72,10 +74,14 @@ class AccountStateController extends Controller {
|
||||
$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 ();
|
||||
|
||||
$account = Account::readDefaultObject();
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
|
||||
@ -94,7 +100,8 @@ class AccountStateController extends Controller {
|
||||
return $this->render ( 'open', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'lastStates' => $lastStates
|
||||
'lastStates' => $lastStates,
|
||||
'account' => $account
|
||||
] );
|
||||
}
|
||||
}
|
||||
@ -111,6 +118,18 @@ class AccountStateController extends Controller {
|
||||
$model->type = AccountState::TYPE_CLOSE;
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
$model->id_account = Account::readDefault ();
|
||||
$account = Account::readDefaultObject();
|
||||
|
||||
$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 +147,23 @@ class AccountStateController extends Controller {
|
||||
return $this->render ( 'close', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'lastStates' => $lastStates
|
||||
'account' => $account,
|
||||
'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.
|
||||
|
||||
@ -24,6 +24,8 @@ use common\models\ShoppingCart;
|
||||
use frontend\models\ReceptionForm;
|
||||
use frontend\models\CustomerCartPayoutForm;
|
||||
use frontend\models\UserCartPayoutForm;
|
||||
use frontend\components\DefaultAccountBehavior;
|
||||
use frontend\components\CassaOpenBehavior;
|
||||
|
||||
/**
|
||||
* ProductController implements the CRUD actions for Product model.
|
||||
@ -61,7 +63,14 @@ class ProductController extends Controller {
|
||||
]
|
||||
// everything else is denied
|
||||
|
||||
]
|
||||
] ,
|
||||
// named behavior, configuration array
|
||||
'defaultAccount' => [
|
||||
'class' => DefaultAccountBehavior::className(),
|
||||
],
|
||||
'cassaIsOpen' => [
|
||||
'class' => CassaOpenBehavior::className(),
|
||||
],
|
||||
];
|
||||
}
|
||||
public function actionSale($number = null) {
|
||||
|
||||
@ -19,6 +19,8 @@ use common\models\User;
|
||||
use common\models\ShoppingCart;
|
||||
use common\models\UserSoldItem;
|
||||
use frontend\components\FrontendController;
|
||||
use frontend\components\DefaultAccountBehavior;
|
||||
use frontend\components\CassaOpenBehavior;
|
||||
|
||||
/**
|
||||
* TicketController implements the CRUD actions for Ticket model.
|
||||
@ -46,6 +48,12 @@ class TicketController extends FrontendController
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
'defaultAccount' => [
|
||||
'class' => DefaultAccountBehavior::className(),
|
||||
],
|
||||
'cassaIsOpen' => [
|
||||
'class' => CassaOpenBehavior::className(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -126,5 +134,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 */
|
||||
?>
|
||||
|
||||
|
||||
@ -15,10 +16,14 @@ use frontend\components\HtmlHelper;
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
<div class='row'>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'id_account')->dropDownList( HtmlHelper::mkAccountOptions($accounts) ) ?>
|
||||
<div class='col-md-8'>
|
||||
<div class="form-group field-accountstate-money required">
|
||||
<label class="control-label" for="accountstate-money">Kassza</label><br>
|
||||
<?php echo ( isset($account) ? $account->name : 'Nincs alapértelmezett kassza kiválasztva!' )?>
|
||||
</div>
|
||||
<?php //echo $form->field($model, 'id_account')->dropDownList( HtmlHelper::mkAccountOptions($accounts) ) ?>
|
||||
</div>
|
||||
<div class='col-md-6'>
|
||||
<div class='col-md-4'>
|
||||
<?= $form->field($model, 'money')->textInput(['class' => 'form-control text-right']); ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -57,7 +62,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>
|
||||
|
||||
@ -6,6 +6,7 @@ use frontend\components\HtmlHelper;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\AccountState */
|
||||
/* @var $account common\models\Account the default account */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
@ -16,12 +17,17 @@ use frontend\components\HtmlHelper;
|
||||
<?php echo Html::activeHiddenInput($model, "prev_state") ?>
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'id_account')->dropDownList( HtmlHelper::mkAccountOptions($accounts) ) ?>
|
||||
</div>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'money')->textInput(['class' => 'form-control text-right']); ?>
|
||||
</div>
|
||||
<div class='col-md-8'>
|
||||
<div class="form-group field-accountstate-money required">
|
||||
<label class="control-label" for="accountstate-money">Kassza</label><br>
|
||||
<?php echo ( isset($account) ? $account->name : 'Nincs alapértelmezett kassza kiválasztva!' )?>
|
||||
</div>
|
||||
|
||||
<?php //echo $form->field($model, 'id_account')->dropDownList( HtmlHelper::mkAccountOptions($accounts) ) ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?= $form->field($model, 'money')->textInput(['class' => 'form-control text-right']); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo $this->render('_notes',[ 'form' => $form, 'model' => $model])?>
|
||||
|
||||
@ -22,6 +22,8 @@ $this->registerJs ( 'new AccountState( '. json_encode($options).');' );
|
||||
<?= $this->render('_form_close', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'account' => $account,
|
||||
'lastCassaState' => $lastCassaState,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
|
||||
@ -24,6 +24,7 @@ $this->registerJs ( 'new AccountState( '. json_encode($options).');' );
|
||||
<?= $this->render('_form_open', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'account' => $account,
|
||||
]) ?>
|
||||
|
||||
</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 } ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user