add ticket original end and original price

add helper links to related object in admin
This commit is contained in:
2017-09-06 12:14:12 +02:00
parent bacfc36487
commit 90d19d17b6
19 changed files with 481 additions and 81 deletions

View File

@@ -101,4 +101,11 @@ class DateUtil
return $formatter->asDatetime($dateTimeObject);
}
public static function parseDate($dateString){
$date = \DateTime::createFromFormat("Y.m.d", $dateString, new \DateTimeZone( 'UTC'));
$date->setTime(0, 0, 0);
return $date;
}
}

View File

@@ -2,6 +2,7 @@
namespace common\components;
use common\models\TicketType;
use common\models\Transfer;
use \Yii;
@@ -493,5 +494,40 @@ class Helper {
}
}
}
/**
* @param $start \DateTime datetime
* @param $ticketType \common\models\TicketType the ticket type
*/
public static function getTicketExpirationDate($start,$ticketType){
$result = new \DateTime();
$result->setTimezone(new \DateTimeZone("UTC") );
$result->setTimestamp($start->getTimestamp());
$unitCount = $ticketType->time_unit_count;
$unitType = $ticketType->time_unit_type;
switch ($unitType){
case TicketType::TIME_UNIT_DAY:
$result->add(new \DateInterval("P".$unitCount."D"));
$result->sub(new \DateInterval("P1D"));
break;
case TicketType::TIME_UNIT_MONTH:
$result->add(new \DateInterval("P".$unitCount."M"));
$result->sub(new \DateInterval("P1D"));
break;
case TicketType::TIME_UNIT_MONTH_REFERENCE:
if ( $unitCount > 1 ){
$result->add(new \DateInterval("P". ($unitCount -1 )."M"));
}
$result->sub(new \DateInterval("P1D"));
break;
}
$result->setTime(0, 0, 0);
return $result;
}
}

View File

@@ -2,6 +2,7 @@
namespace common\models;
use common\components\Helper;
use Yii;
use yii\helpers\Url;
use yii\helpers\VarDumper;
@@ -54,6 +55,43 @@ class Log extends BaseFitnessActiveRecord
public static $TYPE_TOWEL_IN = 190;
public static $TYPE_TOWEL_OUT = 200;
public static $TYPE_CRUD = 210;
public static $TYPE_TICKET_UPDATED_BY_ADMIN = 220;
public static function getTypes(){
return [
Log::$TYPE_INFO => "Info",
Log::$TYPE_ERR => "Hiba",
Log::$TYPE_TICKET_USAGE_FIRST => "Bérlet használat",
Log::$TYPE_TICKET_USAGE_MULTIPLE => "Többszöri bérlet használat",
Log::$TYPE_LOGIN => "Bejelentkezés",
Log::$TYPE_DEFAULT_ACCOUNT=> "Alapértelmezett kassza",
Log::$TYPE_CREATE_CUSTOMER=> "Új vendég",
Log::$TYPE_PROCUREMENT_UPDATE => "Beszerzés módosítás",
Log::$TYPE_TICKET_COUNT_MOVE_OUT => "Ki mozgás",
Log::$TYPE_WASTE => "Selejt",
Log::$TYPE_NEWSLETTER_SUBSCRIBE => "Feliratkozás hirlevélre",
Log::$TYPE_NEWSLETTER_UNSUBSCRIBE => "Leiratkozás hírlevélről",
Log::$TYPE_NEWSLETTER_SENT => "Hirlevél elküldve",
Log::$TYPE_TICKET_EXPIRE_SENT => "Bérlet lejáart figyelmeztetés elküldve",
Log::$TYPE_NEWSLETTER_SEND_START => "Hirlevél küldés start",
Log::$TYPE_NEWSLETTER_SEND_END => "Hirlevél küldés vége",
Log::$TYPE_KEY_ASSIGN => "Kulcs kiadás",
Log::$TYPE_KEY_UNASSIGN => "Kulcs visszaadás",
Log::$TYPE_TOWEL_IN => "Törölköző ki",
Log::$TYPE_TOWEL_OUT => "Törölköző vissza",
Log::$TYPE_CRUD => "CRUD",
Log::$TYPE_TICKET_UPDATED_BY_ADMIN => "Bérlet módosítás"
];
}
public function getTypeName(){
$types = Log::getTypes();
return Helper::getArrayValue($types,$this->type,null);
}
/**
* @inheritdoc
@@ -132,5 +170,47 @@ class Log extends BaseFitnessActiveRecord
$model->id_user = 1;
$model->save(false);
}
public function getUser(){
return $this->hasOne( User::className(), ["id" =>"id_user" ] );
}
public function getTicket(){
return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_ticket" ] );
}
public function getCustomer(){
return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] );
}
public function getMoneyMovement(){
return $this->hasOne( MoneyMovement::className(), ["id_money_movement" =>"id_money_movement" ] );
}
public function getUserName(){
$user = $this->user;
if ( isset($user)){
return $user->username;
}
return null;
}
public function getCustomerName(){
$customer = $this->customer;
if ( isset($customer)){
return $customer->name;
}
return null;
}
public function getTicketName(){
$ticket = $this->ticket;
if ( isset($ticket)){
return $ticket->ticketTypeName;
}
return null;
}
}

View File

@@ -32,6 +32,8 @@ use common\components\Helper;
* @property string $created_at
* @property string $updated_at
* @property int id_contract
* @property integer $original_price
* @property string $original_end;
*
* @property \common\models\Card card
*/
@@ -141,6 +143,8 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
'id_card' => Yii::t('backend/ticket','Card'),
'id_customer' => Yii::t('backend/ticket','Customer'),
'payment_method' => Yii::t('common/transfer', 'Fizetési mód'),
'original_price' => Yii::t('common/transfer', 'Eredeti ár'),
'original_end' => Yii::t('common/transfer', 'Eredeti érvényesség vége'),
];
}
@@ -152,6 +156,10 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
public function getContract(){
return $this->hasOne( Contract::className(), ["id_contract" =>"id_contract" ] );
}
public function getTransfer(){
return $this->hasOne( Transfer::className(), ["id_object" =>"id_ticket"] )->andWhere(['transfer.type' => Transfer::TYPE_TICKET]);
}
public function getCardNumber(){
$result = "";

View File

@@ -197,6 +197,13 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
"id_transfer" => "id_transfer"
] );
}
public function getCustomer(){
return $this->hasOne ( Customer::className (), [
"id_customer" => "id_customer"
] );
}
public function getSale() {
return $this->hasOne ( Sale::className (), [
"id_sale" => "id_object"