customer available events improvements
This commit is contained in:
@@ -44,20 +44,20 @@ use yii\web\IdentityInterface;
|
||||
*/
|
||||
class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
{
|
||||
|
||||
|
||||
const STATUS_DELETED = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
|
||||
|
||||
const SEX_UNKNOWN = 0;
|
||||
const SEX_MAN = 10;
|
||||
const SEX_WOMAN = 20;
|
||||
|
||||
|
||||
|
||||
public static $ENABLED = 1;
|
||||
|
||||
|
||||
public $photo_data;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -65,7 +65,7 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
{
|
||||
return 'customer';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@@ -117,16 +117,16 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
'birth_place' => Yii::t('common/customer', 'Születési hely'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static function statuses() {
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t('common/account', 'Active'),
|
||||
self::STATUS_DELETED => Yii::t('common/account', 'Inactive'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusHuman(){
|
||||
$result = null;
|
||||
$s = self::statuses( );
|
||||
@@ -135,7 +135,7 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
static function sexes() {
|
||||
return [
|
||||
self::SEX_UNKNOWN => Yii::t('common/customer', 'Unknown sex'),
|
||||
@@ -143,7 +143,7 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
self::SEX_WOMAN => Yii::t('common/customer', 'Woman'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getSexHuman(){
|
||||
$result = null;
|
||||
$s = self::sexes( );
|
||||
@@ -152,12 +152,12 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function isInactive(){
|
||||
return $this->status == self::STATUS_DELETED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getCard(){
|
||||
return $this->hasOne ( Card::className (), [
|
||||
'id_card' => 'id_customer_card'
|
||||
@@ -173,7 +173,7 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
'id_image' => 'id_image'
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
public function getCustomerCardNumber(){
|
||||
$result = null;
|
||||
$card = $this->card;
|
||||
@@ -190,17 +190,17 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getFullAddress(){
|
||||
$zip = $this->zip;
|
||||
$city = $this->city;
|
||||
$address = $this->address;
|
||||
|
||||
|
||||
$result = $zip . " " .$city . ", ". $address;
|
||||
return $result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function afterSave($insert, $changedAttributes){
|
||||
if ( !$insert ){
|
||||
Card::updateCardFlagTicket($this->id_customer_card);
|
||||
@@ -295,6 +295,8 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
|
||||
// \Yii::info("pwd", $this->password_hash);
|
||||
// echo $this->password_hash;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -172,6 +172,19 @@ class Event extends ActiveRecord
|
||||
/**
|
||||
* @return EventRegistration[]|ActiveQuery
|
||||
*/
|
||||
public function getActiveEventRegistrationsForCustomer(){
|
||||
return $this->hasMany(EventRegistration::class,['id_event' => 'id'])->andWhere(
|
||||
[
|
||||
'event_registration.canceled_at' => null,
|
||||
'event_registration.deleted_at' => null,
|
||||
'event_registration.id_customer' => \Yii::$app->user->id
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getEventRegistrationCount(){
|
||||
return count($this->getActiveEventRegistrations()->all());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user