Finish version/v.0.0.22

This commit is contained in:
Roland Schneider 2016-01-17 07:12:35 +01:00
commit 2511cff8ff
31 changed files with 464 additions and 57 deletions

View File

@ -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 -0.0.20
- account state email with pdf - account state email with pdf
- login email - login email

View File

@ -9,6 +9,7 @@ use common\models\Account;
use common\models\MoneyMovement; use common\models\MoneyMovement;
use common\components\RoleDefinition; use common\components\RoleDefinition;
use common\models\AccountState;
/** /**
* TransferListSearch represents the model behind the search form about `common\models\Transfer`. * TransferListSearch represents the model behind the search form about `common\models\Transfer`.
*/ */
@ -108,7 +109,15 @@ class DailyListing
public $id_user; public $id_user;
public $type; 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(){ public function readTotalEasy(){
$this->readTicketMoney(); $this->readTicketMoney();
$this->readProductsMoney(); $this->readProductsMoney();
@ -141,6 +150,7 @@ class DailyListing
public function loadAccountState($accountState){ public function loadAccountState($accountState){
$this->mode = 'accountstate'; $this->mode = 'accountstate';
$this->accountState = $accountState;
$this->start = $accountState->start_date; $this->start = $accountState->start_date;
$this->end = $accountState->created_at; $this->end = $accountState->created_at;
$this->timestampStart = $accountState->start_date; $this->timestampStart = $accountState->start_date;
@ -149,13 +159,26 @@ class DailyListing
$this->id_user = $accountState->id_user; $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(){ public function isModeAdmin(){
return $this->mode == 'admin'; return $this->mode == 'admin';
} }
public function isModeAccountState(){ public function isModeAccountState(){
return $this->mode == 'accountstate'; return $this->mode == 'accountstate';
} }
public function isModeReception(){
return $this->mode == 'reception';
}
public function calcTotal(){ public function calcTotal(){
$this->total = 0; $this->total = 0;
@ -170,6 +193,22 @@ class DailyListing
$this->totalNetto += $this->moneyMovementMoneis; $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){ public function addAccountConstraint($query){
@ -513,7 +552,7 @@ class DailyListing
public function readMoneyMovements(){ public function readMoneyMovements(){
$query = (new \yii\db\Query()); $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->from('transfer');
$query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]); $query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]);
$query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object"); $query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object");

View File

@ -161,6 +161,9 @@ class Helper {
public static function isProductVisibilityAccount() { public static function isProductVisibilityAccount() {
return \Yii::$app->params ['product_visiblity'] == 'account'; 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() { public static function getRealUserIp() {
$client = @$_SERVER ['HTTP_CLIENT_IP']; $client = @$_SERVER ['HTTP_CLIENT_IP'];
$forward = @$_SERVER ['HTTP_X_FORWARDED_FOR']; $forward = @$_SERVER ['HTTP_X_FORWARDED_FOR'];

View File

@ -42,9 +42,11 @@ class AccountStateMail extends Object {
$this->details = new DailyListing(); $this->details = new DailyListing();
$this->details->loadAccountState ( $this->model ); $this->details->loadAccountState ( $this->model );
$this->details->readTotalEasy (); $this->details->readModeAccountState();
$this->details->readTotalDetailed ();
$this->details->readTotalMedium (); // $this->details->readTotalEasy ();
// $this->details->readTotalDetailed ();
// $this->details->readTotalMedium ();
} }
} }
@ -61,7 +63,7 @@ class AccountStateMail extends Object {
$this->attachPdf(); $this->attachPdf();
$this->message->setFrom('noreplay@fitnessadmin.hu') $this->message->setFrom(\Yii::$app->params['infoEmail'])
->setTo( \Yii::$app->params['notify_mail'] ) ->setTo( \Yii::$app->params['notify_mail'] )
->setSubject($subject ) ->setSubject($subject )
->send(); ->send();

View File

@ -0,0 +1,9 @@
<?php
namespace common\components\total;
class TotalCassaOpenInfoWidget extends TotalBaseWidget{
public $viewFile = 'total_cassa_open.php';
}

View File

@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com', 'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu', 'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600, 'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.20', 'version' => 'v0.0.22',
'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
@ -12,5 +12,6 @@ return [
'mail_account_state_open' => true, 'mail_account_state_open' => true,
'login_reception_email' => true, //if reception login should send email 'login_reception_email' => true, //if reception login should send email
'login_admin_email' => true, //if admin 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
]; ];

View File

@ -13,6 +13,7 @@ use common\components\total\TotalDifferenceWidget;
use common\models\AccountState; use common\models\AccountState;
use yii\helpers\Url; use yii\helpers\Url;
use common\components\accountstate\AccountStateWidget; use common\components\accountstate\AccountStateWidget;
use common\components\total\TotalCassaOpenInfoWidget;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\AccountState */ /* @var $model common\models\AccountState */
@ -72,6 +73,8 @@ if ( $model ->type == AccountState::TYPE_OPEN ){
<?php if ( $model ->type == AccountState::TYPE_CLOSE ){?> <?php if ( $model ->type == AccountState::TYPE_CLOSE ){?>
<?php echo TotalEasyWidget::widget(['dailyListing' => $details]);?> <?php echo TotalEasyWidget::widget(['dailyListing' => $details]);?>
<?php echo TotalCassaOpenInfoWidget::widget(['dailyListing' => $details]);?>
<h2>Közepes összesítés</h2> <h2>Közepes összesítés</h2>
<h3>Bérletek típus szerint</h3> <h3>Bérletek típus szerint</h3>
<?php echo TotalMediumTicketsWidget::widget(['dailyListing' => $details]);?> <?php echo TotalMediumTicketsWidget::widget(['dailyListing' => $details]);?>

View File

@ -34,7 +34,7 @@ return [
'Id Account' => 'Kassza', 'Id Account' => 'Kassza',
'Id Account State' => 'Kassza művelet', 'Id Account State' => 'Kassza művelet',
'Id User' => 'Felhasználó', 'Id User' => 'Felhasználó',
'Money' => 'Összeg', 'Money' => 'Kasszában lévő összeg',
'Type' => 'Típus', 'Type' => 'Típus',
'Updated At' => 'Módosítás ideje', 'Updated At' => 'Módosítás ideje',
]; ];

View File

@ -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( ){ public static function readDefault( ){
$session = Yii::$app->session; $session = Yii::$app->session;
$result = $session->get('id_account'); $result = $session->get('id_account');
return $result; 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;
} }

View File

@ -3,8 +3,8 @@
namespace common\models; namespace common\models;
use Yii; use Yii;
use yii\db\QueryBuilder;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\behaviors\TimestampBehavior;
/** /**
* This is the model class for table "account_state". * This is the model class for table "account_state".
@ -38,6 +38,17 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
public $start_date; public $start_date;
/**
* @inheritdoc
*/
// public function behaviors()
// {
// return [[
// 'class' => TimestampBehavior::className(),
// 'value' => function(){ return date('Y-m-d H:i' ); }
// ] ];
// }
/** /**
* @inheritdoc * @inheritdoc
*/ */
@ -52,11 +63,10 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['id_account','money' ], 'required'], [['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'], [['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], [['comment' ], 'string' ,'max' => 255],
[['prev_state' ], 'integer'], [['prev_state' ], 'integer'],
[['id_account'] , 'validatePrevState'],
]; ];
} }
@ -183,6 +193,8 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
* Read last accountstates * Read last accountstates
* @param $type int the type of accountstate to load * @param $type int the type of accountstate to load
* @param $user $id of user to load the account * @param $user $id of user to load the account
* @return common\models\AccountState
*
* */ * */
public static function readLast($type, $user = null,$account = null){ public static function readLast($type, $user = null,$account = null){
$result = null; $result = null;
@ -191,9 +203,13 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
if ( isset($type)){ if ( isset($type)){
$query->andWhere(['account_state.type' => $type]); $query->andWhere(['account_state.type' => $type]);
} }
if ( $account ){ if ( isset( $account ) ){
$query->andWhere(["account_state.id_account" => $account ]); $query->andWhere(["account_state.id_account" => $account ]);
} }
if ( isset( $user ) ){
$query->andWhere(["account_state.id_user" => $user ]);
}
$query->limit(1); $query->limit(1);

View File

@ -46,14 +46,17 @@ class Product extends \common\models\BaseFitnessActiveRecord {
[['id_product_category', 'id_account', 'name'], 'required'], [['id_product_category', 'id_account', 'name'], 'required'],
[['id_product_category', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'], [['id_product_category', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'],
[['product_number', 'barcode'], 'string', 'max' => 20], [['product_number', 'barcode'], 'string', 'max' => 20],
[['product_number', 'barcode'], 'filter', 'filter' => 'trim', 'skipOnArray' => true],
[['name'], 'string', 'max' => 128], [['name'], 'string', 'max' => 128],
[['description'], 'string', 'max' => 255], [['description'], 'string', 'max' => 255],
[['product_number'], 'unique' ], // [['product_number'], 'unique' ],
[['barcode'], 'unique' ], // [['barcode'], 'unique' ],
// a1 and a2 need to be unique together, only a1 will receive error message // a1 and a2 need to be unique together, only a1 will receive error message
// ['a1', 'unique', 'targetAttribute' => ['a1', 'a2']] // ['a1', 'unique', 'targetAttribute' => ['a1', 'a2']]
[['barcode','product_number'], 'filter', 'filter' => function($value){return Helper::fixAsciiChars($value);}],
['barcode', 'unique', 'targetAttribute' => ['id_account', 'barcode']], ['barcode', 'unique', 'targetAttribute' => ['id_account', 'barcode']],
['product_number', 'unique', 'targetAttribute' => ['id_account', 'product_number']], ['product_number', 'unique', 'targetAttribute' => ['id_account', 'product_number']],
]; ];
} }

View File

@ -165,10 +165,11 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
$query = Ticket::find(); $query = Ticket::find();
$today = date('Y-m-d'); $today = date('Y-m-d');
$query->andWhere(['id_card' => $card->id_card]); $query->andWhere(['ticket.id_card' => $card->id_card]);
$query->andWhere( 'start <= :today' ,[ 'today' => $today] ); $query->andWhere( 'ticket.start <= :today' ,[ 'today' => $today] );
$query->andWhere( 'end >= :today' ,[ 'today' => $today] ); $query->andWhere( 'ticket.end >= :today' ,[ 'today' => $today] );
$query->orderBy([ "created_at" =>SORT_DESC] ); $query->andWhere( 'ticket.status = :status' ,[ 'status' => Ticket::STATUS_ACTIVE] );
$query->orderBy([ "ticket.created_at" =>SORT_DESC] );
$result = $query->all(); $result = $query->all();
return $result; return $result;

View File

@ -14,6 +14,7 @@ use common\models\Account;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use common\models\MoneyMovement; use common\models\MoneyMovement;
use common\components\RoleDefinition; use common\components\RoleDefinition;
use common\components\Helper;
/** /**
* TransferListSearch represents the model behind the search form about `common\models\Transfer`. * 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 public $mode = "reception";//reception or admin
/**start date string*/
public $start; public $start;
/**end date string*/
public $end; public $end;
/**start date*/
public $timestampStart; public $timestampStart;
/** end date*/
public $timestampEnd; public $timestampEnd;
/**if include cassa open*/
public $includeCassaOpen = false;
/**total with cassa open*/
// public $totalsCreatedAt = ['total' => 0, 'accounts' =>[] ]; public $totalWithCassa;
// public $totalsCreatedAtNotPaid= ['total' => 0, 'accounts' =>[]]; /**last cassa open*/
// public $totalsCreatedAtPaid= ['total' => 0, 'accounts' =>[]]; public $cassaOpen;
// public $totalsPaidAt= ['total' => 0, 'accounts' =>[]];
// public $totalsPaidAtNotCreatedAt= ['total' => 0, 'accounts' =>[]];
public $totals; public $totals;
/**The accounts*/
public $accounts; public $accounts;
/**types*/
public $types; public $types;
/**users*/
public $users; public $users;
/** /**
* all money gained with ticket sell * all money gained with ticket sell
* */ * */
@ -124,6 +123,9 @@ class TransferListSearch extends Transfer
public function isModeAdmin(){ public function isModeAdmin(){
return $this->mode == 'admin'; return $this->mode == 'admin';
} }
public function isModeReception(){
return $this->mode == 'reception';
}
/** /**
* Creates data provider instance with search query applied * Creates data provider instance with search query applied
@ -149,11 +151,20 @@ class TransferListSearch extends Transfer
} }
$this->readTicketMoney(); $this->readTicketMoney();
$this->readProductsMoney(); $this->readProductsMoney();
$this->readMoneyMovementMoney(); $this->readMoneyMovementMoney();
$this->calcTotal(); $this->calcTotal();
if ( $this->isModeReception()){
if ( Helper::isAccountStateClosePreloadMoney()){
$this->readCassaOpen();
$this->calcTotalWithCassaOpen();
}
}
$this->readProductsByCategory(); $this->readProductsByCategory();
$this->readProductsByCategoryDetailed(); $this->readProductsByCategoryDetailed();
$this->readTicketStas(); $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(){ protected function calcTotal(){
$this->total = 0; $this->total = 0;
$this->total += $this->ticketMoney; $this->total += $this->ticketMoney;
$this->total += $this->productMoney; $this->total += $this->productMoney;
$this->total += $this->moneyMovementMoneis; $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(){ protected function calcTotalNetto(){
$this->totalNetto = 0; $this->totalNetto = 0;
$this->totalNetto += $this->ticketMoney; $this->totalNetto += $this->ticketMoney;
@ -437,7 +460,7 @@ class TransferListSearch extends Transfer
protected function readMoneyMovements(){ protected function readMoneyMovements(){
$query = (new \yii\db\Query()); $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->from('transfer');
$query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]); $query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]);
$query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object"); $query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object");

View File

@ -62,6 +62,9 @@ if ( $model ->type == AccountState::TYPE_OPEN ){
<?php <?php
echo AccountStateWidget::widget(['model' => $model]); echo AccountStateWidget::widget(['model' => $model]);
?> ?>
<?php if ( $model->hasDifferenceToPrevState() ){ <?php if ( $model->hasDifferenceToPrevState() ){
?> ?>

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

View File

@ -8,6 +8,7 @@
<th>Név</th> <th>Név</th>
<th>Típus</th> <th>Típus</th>
<th>Összeg</th> <th>Összeg</th>
<th>Megjegyzés</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -19,6 +20,7 @@
<td><?php echo $p['money_movement_name'] ?></td> <td><?php echo $p['money_movement_name'] ?></td>
<td><?php echo $p['money_movement_type_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 class='money'><?php echo \Yii::$app->formatter->asInteger( $p['signed_money'])?> Ft</td>
<td><?php echo $p['money_movement_comment'] ?></td>
</tr> </tr>
<?php } ?> <?php } ?>

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

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

View File

@ -84,7 +84,7 @@ class FrontendMenuStructure{
if ( $isadmin || Yii::$app->user->can('reception.transfers') ){ 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/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' ] ]; $items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ];

View File

@ -12,6 +12,8 @@ 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; use common\components\accountstate\AccountStateMail;
use common\models\Transfer;
use common\components\Helper;
/** /**
* AccountStateController implements the CRUD actions for AccountState model. * AccountStateController implements the CRUD actions for AccountState model.
@ -72,10 +74,14 @@ class AccountStateController extends Controller {
$lastStates = AccountState::readLastForUser ( AccountState::TYPE_CLOSE ); $lastStates = AccountState::readLastForUser ( AccountState::TYPE_CLOSE );
$lastStates = AccountState::modelsToArray ( $lastStates ); $lastStates = AccountState::modelsToArray ( $lastStates );
$model = new AccountState (); $model = new AccountState ();
$model->type = AccountState::TYPE_OPEN; $model->type = AccountState::TYPE_OPEN;
$model->id_user = Yii::$app->user->id; $model->id_user = Yii::$app->user->id;
$model->id_account = Account::readDefault (); $model->id_account = Account::readDefault ();
$account = Account::readDefaultObject();
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]);
@ -94,7 +100,8 @@ class AccountStateController extends Controller {
return $this->render ( 'open', [ return $this->render ( 'open', [
'model' => $model, 'model' => $model,
'accounts' => $accounts, 'accounts' => $accounts,
'lastStates' => $lastStates 'lastStates' => $lastStates,
'account' => $account
] ); ] );
} }
} }
@ -111,6 +118,18 @@ class AccountStateController extends Controller {
$model->type = AccountState::TYPE_CLOSE; $model->type = AccountState::TYPE_CLOSE;
$model->id_user = Yii::$app->user->id; $model->id_user = Yii::$app->user->id;
$model->id_account = Account::readDefault (); $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 ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
@ -128,11 +147,23 @@ class AccountStateController extends Controller {
return $this->render ( 'close', [ return $this->render ( 'close', [
'model' => $model, 'model' => $model,
'accounts' => $accounts, '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. * Finds the AccountState model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.

View File

@ -24,6 +24,8 @@ use common\models\ShoppingCart;
use frontend\models\ReceptionForm; use frontend\models\ReceptionForm;
use frontend\models\CustomerCartPayoutForm; use frontend\models\CustomerCartPayoutForm;
use frontend\models\UserCartPayoutForm; use frontend\models\UserCartPayoutForm;
use frontend\components\DefaultAccountBehavior;
use frontend\components\CassaOpenBehavior;
/** /**
* ProductController implements the CRUD actions for Product model. * ProductController implements the CRUD actions for Product model.
@ -61,7 +63,14 @@ class ProductController extends Controller {
] ]
// everything else is denied // everything else is denied
] ] ,
// named behavior, configuration array
'defaultAccount' => [
'class' => DefaultAccountBehavior::className(),
],
'cassaIsOpen' => [
'class' => CassaOpenBehavior::className(),
],
]; ];
} }
public function actionSale($number = null) { public function actionSale($number = null) {

View File

@ -19,6 +19,8 @@ use common\models\User;
use common\models\ShoppingCart; use common\models\ShoppingCart;
use common\models\UserSoldItem; use common\models\UserSoldItem;
use frontend\components\FrontendController; use frontend\components\FrontendController;
use frontend\components\DefaultAccountBehavior;
use frontend\components\CassaOpenBehavior;
/** /**
* TicketController implements the CRUD actions for Ticket model. * TicketController implements the CRUD actions for Ticket model.
@ -46,6 +48,12 @@ class TicketController extends FrontendController
// everything else is denied // everything else is denied
], ],
], ],
'defaultAccount' => [
'class' => DefaultAccountBehavior::className(),
],
'cassaIsOpen' => [
'class' => CassaOpenBehavior::className(),
],
]; ];
} }
@ -126,5 +134,54 @@ class TicketController extends FrontendController
'receptionForm' => $receptionForm, '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.');
}
}
} }

View File

@ -9,6 +9,7 @@ use common\models\Customer;
use common\models\Ticket; use common\models\Ticket;
use common\models\Account; use common\models\Account;
use common\models\CardSearch; use common\models\CardSearch;
use common\models\AccountState;
/** /**
* ContactForm is the model behind the contact form. * ContactForm is the model behind the contact form.
@ -21,6 +22,7 @@ class ReceptionForm extends Model
public $tickets; public $tickets;
public $defaultAccount; public $defaultAccount;
public $cardSearchModel; public $cardSearchModel;
public $lastCassaState;
/** /**
* @inheritdoc * @inheritdoc
@ -58,10 +60,33 @@ class ReceptionForm extends Model
$this->defaultAccount = Account::findOne($defaultAccount); $this->defaultAccount = Account::findOne($defaultAccount);
} }
$this->readLastCassaState();
$this->cardSearchModel = new CardSearch(); $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(){ public function getDefaultAccountName(){
$result = ""; $result = "";
if ( $this->defaultAccount ){ if ( $this->defaultAccount ){

View File

@ -7,6 +7,7 @@ use frontend\components\HtmlHelper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\AccountState */ /* @var $model common\models\AccountState */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
/* @var $lastCassaState common\models\AccountState */
?> ?>
@ -15,10 +16,14 @@ use frontend\components\HtmlHelper;
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<div class='row'> <div class='row'>
<div class='col-md-6'> <div class='col-md-8'>
<?= $form->field($model, 'id_account')->dropDownList( HtmlHelper::mkAccountOptions($accounts) ) ?> <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>
<div class='col-md-6'> <div class='col-md-4'>
<?= $form->field($model, 'money')->textInput(['class' => 'form-control text-right']); ?> <?= $form->field($model, 'money')->textInput(['class' => 'form-control text-right']); ?>
</div> </div>
</div> </div>
@ -57,7 +62,6 @@ use frontend\components\HtmlHelper;
<div class="form-group"> <div class="form-group">
<?= Html::submitButton( Yii::t('frontend/account-state', 'Close account'), ['class' => 'btn btn-primary']) ?> <?= Html::submitButton( Yii::t('frontend/account-state', 'Close account'), ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>

View File

@ -6,6 +6,7 @@ use frontend\components\HtmlHelper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\AccountState */ /* @var $model common\models\AccountState */
/* @var $account common\models\Account the default account */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
?> ?>
@ -16,12 +17,17 @@ use frontend\components\HtmlHelper;
<?php echo Html::activeHiddenInput($model, "prev_state") ?> <?php echo Html::activeHiddenInput($model, "prev_state") ?>
<div class='row'> <div class='row'>
<div class='col-md-6'> <div class='col-md-8'>
<?= $form->field($model, 'id_account')->dropDownList( HtmlHelper::mkAccountOptions($accounts) ) ?> <div class="form-group field-accountstate-money required">
</div> <label class="control-label" for="accountstate-money">Kassza</label><br>
<div class='col-md-6'> <?php echo ( isset($account) ? $account->name : 'Nincs alapértelmezett kassza kiválasztva!' )?>
<?= $form->field($model, 'money')->textInput(['class' => 'form-control text-right']); ?> </div>
</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> </div>
<?php echo $this->render('_notes',[ 'form' => $form, 'model' => $model])?> <?php echo $this->render('_notes',[ 'form' => $form, 'model' => $model])?>

View File

@ -22,6 +22,8 @@ $this->registerJs ( 'new AccountState( '. json_encode($options).');' );
<?= $this->render('_form_close', [ <?= $this->render('_form_close', [
'model' => $model, 'model' => $model,
'accounts' => $accounts, 'accounts' => $accounts,
'account' => $account,
'lastCassaState' => $lastCassaState,
]) ?> ]) ?>
</div> </div>

View File

@ -24,6 +24,7 @@ $this->registerJs ( 'new AccountState( '. json_encode($options).');' );
<?= $this->render('_form_open', [ <?= $this->render('_form_open', [
'model' => $model, 'model' => $model,
'accounts' => $accounts, 'accounts' => $accounts,
'account' => $account,
]) ?> ]) ?>
</div> </div>

View File

@ -8,11 +8,25 @@ use frontend\components\ReceptionTicketWidget;
use frontend\components\ReceptionCustomerWidget; use frontend\components\ReceptionCustomerWidget;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
use yii\helpers\Html; 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='row'>
<div class='col-md-4'> <div class='col-md-4'>
<div class="alert alert-info"> <div class="alert alert-<?php echo $alertClass;?>">
Aktuális kassza: <?php echo $model->getDefaultAccountName();?> Aktuális kassza: <?php echo $model->getDefaultAccountName();?> -
<?php echo $cassaMessage;?>
</div> </div>
</div> </div>
<?php $form = ActiveForm::begin([ <?php $form = ActiveForm::begin([

View File

@ -32,6 +32,10 @@ $this->params['breadcrumbs'][] = $this->title;
'name', 'name',
'money', 'money',
'created_at:datetime', 'created_at:datetime',
[
'attribute' => 'comment',
'format' => 'html'
],
['class' => 'yii\grid\ActionColumn', ['class' => 'yii\grid\ActionColumn',
'template' => '{view}' 'template' => '{view}'

View File

@ -59,11 +59,9 @@ $this->params['breadcrumbs'][] = $this->title;
*/ */
'price_brutto', 'price_brutto',
'created_at:datetime', 'created_at:datetime',
/*
['class' => 'yii\grid\ActionColumn', ['class' => 'yii\grid\ActionColumn',
'template' =>'{view} {update}', 'template' =>'{delete}',
], ],
*/
], ],
]); ?> ]); ?>

View File

@ -3,9 +3,11 @@ use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
use yii\widgets\ListView; use yii\widgets\ListView;
use yii\base\Widget; use yii\base\Widget;
use yii\helpers\Url;
use common\components\Helper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel common\models\TransferSearch */ /* @var $searchModel common\models\TransferListSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t ( 'frontend/transfer', 'Daily transfers' ); $this->title = Yii::t ( 'frontend/transfer', 'Daily transfers' );
@ -82,10 +84,31 @@ td.name{
</tr> </tr>
<tr> <tr>
<th>Végösszeg</th> <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> </tr>
</tbody> </tbody>
</table> </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>
<div role="tabpanel" class="tab-pane" id="medium"> <div role="tabpanel" class="tab-pane" id="medium">
<h2>Közepes összesítés</h2> <h2>Közepes összesítés</h2>
@ -351,6 +374,7 @@ td.name{
<th>Név</th> <th>Név</th>
<th>Típus</th> <th>Típus</th>
<th>Összeg</th> <th>Összeg</th>
<th>Megjegyzés</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -362,6 +386,7 @@ td.name{
<td><?php echo $p['money_movement_name'] ?></td> <td><?php echo $p['money_movement_name'] ?></td>
<td><?php echo $p['money_movement_type_name'] ?></td> <td><?php echo $p['money_movement_type_name'] ?></td>
<td class='money'><?php echo $p['signed_money']?> Ft</td> <td class='money'><?php echo $p['signed_money']?> Ft</td>
<td><?php echo $p['money_movement_comment'] ?></td>
</tr> </tr>
<?php } ?> <?php } ?>