add backend transfer list changes
This commit is contained in:
@@ -124,4 +124,27 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param common\models\Card $card the card to which we are looking for
|
||||
* */
|
||||
public static function readActive($card){
|
||||
|
||||
if ( $card == null )
|
||||
return [];
|
||||
|
||||
$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] );
|
||||
|
||||
$result = $query->all();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,12 +79,21 @@ class Transfer extends \yii\db\ActiveRecord
|
||||
];
|
||||
}
|
||||
|
||||
public function getUser(){
|
||||
return $this->hasOne( User::className(), ["id" =>"id_user" ] );
|
||||
}
|
||||
|
||||
public function getProduct(){
|
||||
return $this->hasOne( Product::className(), ["id_product" =>"id_object" ] );
|
||||
}
|
||||
|
||||
public function getTicket(){
|
||||
return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_object" ] );
|
||||
}
|
||||
|
||||
public function getTicketType(){
|
||||
return $this->hasOne( TicketType::className(), ["id_ticket_type" =>"id_ticket_type" ] )->via('ticket') ;
|
||||
}
|
||||
|
||||
public function getAccount(){
|
||||
return $this->hasOne( Account::className(), ["id_account" =>"id_account" ] ) ;
|
||||
@@ -102,6 +111,65 @@ class Transfer extends \yii\db\ActiveRecord
|
||||
return $this->hasOne( UserSoldItem::className(), ["id_transfer" =>"id_transfer" ] );
|
||||
}
|
||||
|
||||
public function getObjectName(){
|
||||
$result = "";
|
||||
if ( $this->type == Transfer::TYPE_TICKET ){
|
||||
$result = $this->ticketName;
|
||||
}else{
|
||||
$result = $this->productName;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function getUserName(){
|
||||
$result = "";
|
||||
$user = $this->user;
|
||||
if (isset($this->user)){
|
||||
$result = $user->username;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getProductName(){
|
||||
$result = "";
|
||||
$product = $this->product;
|
||||
if (isset($product)){
|
||||
$result = $product->name;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTicketName(){
|
||||
$result = "";
|
||||
$ticket = $this->ticket;
|
||||
if (isset($ticket)){
|
||||
$result = $this->ticket->ticketTypeName;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function getAccountName(){
|
||||
$result = "";
|
||||
$account = $this->account;
|
||||
if (isset($account)){
|
||||
$result = $account->name;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTransferTypeName(){
|
||||
$result = "";
|
||||
if ( $this->type == Transfer::TYPE_TICKET ){
|
||||
$result = Yii::t('common/transfer','Ticket');
|
||||
}else{
|
||||
$result = Yii::t('common/transfer','Product');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function toProductSoldString(){
|
||||
$s = "";
|
||||
@@ -239,4 +307,11 @@ class Transfer extends \yii\db\ActiveRecord
|
||||
return $transfers;
|
||||
}
|
||||
|
||||
public static function types( ) {
|
||||
return [
|
||||
self::TYPE_PRODUCT => Yii::t('common/transfer','Product'),
|
||||
self::TYPE_TICKET => Yii::t('common/transfer','Ticket'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user