Finish version/v.0.0.31

This commit is contained in:
Roland Schneider 2016-02-02 22:06:40 +01:00
commit 5cd6eb8d99
8 changed files with 159 additions and 18 deletions

View File

@ -1,3 +1,5 @@
-0.0.31
- Add transfer list and daily list to see only may 3 days old data
-0.0.30 -0.0.30
- fix discount to integer ( using floor ) - fix discount to integer ( using floor )
-0.0.29 -0.0.29

View File

@ -118,6 +118,23 @@ class DailyListing
public $accountState; //the cassa object for we load the data public $accountState; //the cassa object for we load the data
protected function calcStartDaysSinceToday(){
$start = $this->timestampStart;
$now = time();
$d = \DateTime::createFromFormat("Y-m-d H:i", $start)->getTimeStamp();
$days_between = ceil(abs($now - $d) / 86400);
return $days_between;
}
protected function isStartDateToEarly(){
$days_visiblity = Helper::getReceptionVisibilityDays();
$days_between = $this->calcStartDaysSinceToday();
return $days_between > $days_visiblity;
}
public function readTotalEasy(){ public function readTotalEasy(){
$this->readTicketMoney(); $this->readTicketMoney();
$this->readProductsMoney(); $this->readProductsMoney();
@ -173,9 +190,11 @@ class DailyListing
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(){ public function isModeReception(){
return $this->mode == 'reception'; return $this->mode == 'reception';
} }
@ -255,6 +274,19 @@ class DailyListing
if ( $this->isModeReception() || $this->isModeAccountState() ){ if ( $this->isModeReception() || $this->isModeAccountState() ){
$query->andWhere(['transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH]); $query->andWhere(['transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH]);
} }
if ( !RoleDefinition::isAdmin() ){
if ( $this->isStartDateToEarly() ){
$time = date( "Y-m-d H:i:s", strtotime("today -3 day") );
$start_date_condition = ['or',[ '>=', 'transfer.created_at', $time ] ,[ '>=', 'transfer.paid_at', $time] ];
$query->andFilterWhere( $start_date_condition );
}
}
} }

View File

@ -182,6 +182,11 @@ class Helper {
public static function isAccountStateClosePreloadMoney() { public static function isAccountStateClosePreloadMoney() {
return \Yii::$app->params ['account_state_close_preload_money'] == true; return \Yii::$app->params ['account_state_close_preload_money'] == true;
} }
public static function getReceptionVisibilityDays() {
return \Yii::$app->params ['reception_visibility_days'] ;
}
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

@ -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.30', 'version' => 'v0.0.31',
'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
@ -20,4 +20,8 @@ return [
//vagy mindent //vagy mindent
//értékek user|all //értékek user|all
'user_cart_item_visibility' => 'user', 'user_cart_item_visibility' => 'user',
/**
* Hány napig láthatják visszamenőleg a recepciósok az adatokat
* */
'reception_visibility_days' => 3
]; ];

View File

@ -430,6 +430,9 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
return $transfer; return $transfer;
} }
public static function modelsToArray($transfers, $default = []) { public static function modelsToArray($transfers, $default = []) {
if ($transfers == null) { if ($transfers == null) {
return $default; return $default;

View File

@ -48,51 +48,51 @@ class TransferListSearch extends Transfer
/** /**
* all money gained with ticket sell * all money gained with ticket sell
* */ * */
public $ticketMoney; public $ticketMoney = 0;
/** /**
* all money gained with product sell * all money gained with product sell
* */ * */
public $productMoney; public $productMoney = 0;
/** /**
* all money gained with product sell * all money gained with product sell
* */ * */
public $productMoneyNetto; public $productMoneyNetto = 0;
/** /**
* all money gained with product sell grouped by category * all money gained with product sell grouped by category
* */ * */
public $productMoneies; public $productMoneies = [];
/** /**
* all money lost by money movement * all money lost by money movement
* */ * */
public $moneyMovementMoneis; public $moneyMovementMoneis = 0;
public $moneyMovementMoney; public $moneyMovementMoney = 0;
/** /**
* total gained money brutto * total gained money brutto
* */ * */
public $total; public $total = 0;
/** /**
* total gained money netto * total gained money netto
* */ * */
public $totalNetto; public $totalNetto = 0;
/** /**
* ticket sale statisitc * ticket sale statisitc
* */ * */
public $ticketStats; public $ticketStats =[];
/** /**
* money movements by type * money movements by type
* */ * */
public $moneyMovementsByType; public $moneyMovementsByType = [];
public $tickets; public $tickets;
/** /**
* all product transfer * all product transfer
* */ * */
public $products; public $products = [];
public $moneyMovements; public $moneyMovements = [];
public $productsByCategory; public $productsByCategory = [];
public $currentUser; public $currentUser;
public $currentAccount; public $currentAccount;
@ -112,14 +112,43 @@ class TransferListSearch extends Transfer
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], [[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], [[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
[['start','end' ], 'required'],
[ [ 'id_account','id_user' ] , 'integer'], [ [ 'id_account','id_user' ] , 'integer'],
['types', 'each', 'rule' => ['integer']], ['types', 'each', 'rule' => ['integer']],
['output', 'safe' ], ['output', 'safe' ],
['outputView', 'safe' ], ['outputView', 'safe' ],
// ['start', 'validateStart']
]; ];
} }
public function validateStart($attribute,$param){
if ( $this->isStartDateToEarly() ){
$this->addError($attribute,"Érvénytelen kezdő dátum");
}
}
protected function calcStartDaysSinceToday(){
$start = $this->timestampStart;
$now = time();
$d = \DateTime::createFromFormat("Y-m-d H:i", $start)->getTimeStamp();
$days_between = ceil(abs($now - $d) / 86400);
return $days_between;
}
protected function isStartDateToEarly(){
$days_visiblity = Helper::getReceptionVisibilityDays();
$days_between = $this->calcStartDaysSinceToday();
return $days_between > $days_visiblity;
}
public function isModeAdmin(){ public function isModeAdmin(){
return $this->mode == 'admin'; return $this->mode == 'admin';
} }
@ -253,9 +282,33 @@ class TransferListSearch extends Transfer
$query->andFilterWhere(['or' , $created_condition , $paid_condition]); $query->andFilterWhere(['or' , $created_condition , $paid_condition]);
$query->andWhere(['transfer.status' => Transfer::STATUS_PAID]); $query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
if ( !$this->isModeAdmin()){ if ( !$this->isModeAdmin()){
$query->andWhere(['transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH]); $query->andWhere(['transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH]);
} }
if ( !RoleDefinition::isAdmin() ){
/**
* Csak az admin láthat minden adatot
* ha a start dátum korábbi, mint ahogy azt a recepciósok láthatják,
* hozzáadjuk a querykhez a dátum korlátozást
* */
if ( $this->isStartDateToEarly() ){
$days = Helper::getReceptionVisibilityDays();
$time = date( "Y-m-d H:i:s", strtotime("today -$days day") );
$start_date_condition = ['or',[ '>=', 'transfer.created_at', $time ] ,[ '>=', 'transfer.paid_at', $time] ];
$query->andFilterWhere( $start_date_condition );
}
}
} }

View File

@ -26,6 +26,7 @@ class TicketCreate extends Ticket{
public $_account; public $_account;
public $_discount; public $_discount;
public $_transfer; public $_transfer;
public $_ticketType;
public $customer; public $customer;
@ -92,6 +93,7 @@ class TicketCreate extends Ticket{
public function validateTicketType($attribute,$params){ public function validateTicketType($attribute,$params){
$type = TicketType::findOne($this->id_ticket_type); $type = TicketType::findOne($this->id_ticket_type);
$this->_ticketType = $type;
if ( !isset($type)) { if ( !isset($type)) {
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid ticket type' )); $this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid ticket type' ));
}else{ }else{
@ -185,8 +187,28 @@ class TicketCreate extends Ticket{
} }
protected function addTransfer(){ protected function addTransfer(){
$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this); //$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
$transfer = new Transfer();
$transfer->type = Transfer::TYPE_TICKET;
$transfer->direction = Transfer::DIRECTION_IN;
$transfer->id_object = $this->id_ticket;
$transfer->item_price = $this->_ticketType->price_brutto;
$transfer->count = 1;
if (isset ( $this->_discount )) {
$transfer->id_discount = $this->_discount->id_discount;
}
$transfer->money = $this->price_brutto;
$transfer->id_account = $this->_account->id_account;
$status = Transfer::STATUS_PAID; $status = Transfer::STATUS_PAID;
if ( $this->isAppendToUserCart() ){ if ( $this->isAppendToUserCart() ){
$status = Transfer::STATUS_NOT_PAID; $status = Transfer::STATUS_NOT_PAID;
@ -206,10 +228,15 @@ class TicketCreate extends Ticket{
} }
$transfer->id_user = \Yii::$app->user->id; $transfer->id_user = \Yii::$app->user->id;
$transfer->id_customer = $this->customer->id_customer; $transfer->id_customer = $this->customer->id_customer;
$transfer->save(); if ( !$transfer->save(false) ){
\Yii::error("Nem sikerült mentenei a bérlet tranzakció objektumot!");
throw new \Exception("Nem sikerült menteni a bérlet tranzakciót");
}
$this->_transfer = $transfer; $this->_transfer = $transfer;
} }
protected function addToCart(){ protected function addToCart(){
if ( $this->isAddToCart()){ if ( $this->isAddToCart()){
$item = new UserSoldItem(); $item = new UserSoldItem();
@ -242,7 +269,10 @@ class TicketCreate extends Ticket{
$item = new UserSoldItem(); $item = new UserSoldItem();
$item->id_transfer = $this->_transfer->id_transfer; $item->id_transfer = $this->_transfer->id_transfer;
$item->id_user = \Yii::$app->user->id; $item->id_user = \Yii::$app->user->id;
$item->save(false); if ( !$item->save(false) ){
\Yii::error("Nem sikerült menteni a bérletet! Recepció kosár hozzárendelés sikertelen!");
throw new \Exception("Nem sikerült menteni a bérletet! Recepció kosár hozzárendelés sikertelen!");
}
} }
} }
@ -251,7 +281,11 @@ class TicketCreate extends Ticket{
$item = new ShoppingCart(); $item = new ShoppingCart();
$item->id_customer = $this->customer->id_customer; $item->id_customer = $this->customer->id_customer;
$item->id_transfer = $this->_transfer->id_transfer; $item->id_transfer = $this->_transfer->id_transfer;
$item->save(false); if ( !$item->save(false) ){
\Yii::error("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
throw new \Exception("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
}
} }
} }

View File

@ -46,6 +46,14 @@ td.name{
} }
</style> </style>
<?php
?>
<div class="transfer-index"> <div class="transfer-index">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>