add frontend ticket translations
This commit is contained in:
@@ -6,12 +6,17 @@ use common\models\TicketType;
|
||||
use common\models\Account;
|
||||
use common\models\Discount;
|
||||
use common\models\Transfer;
|
||||
use common\models\UserSoldItem;
|
||||
use yii\base\Object;
|
||||
|
||||
class TicketCreate extends Ticket{
|
||||
|
||||
public $_currency;
|
||||
public $_account;
|
||||
public $_discount;
|
||||
public $_transfer;
|
||||
|
||||
public $cart;
|
||||
|
||||
public function rules()
|
||||
{
|
||||
@@ -51,7 +56,11 @@ class TicketCreate extends Ticket{
|
||||
/////////////////////
|
||||
//comment
|
||||
/////////////////////
|
||||
[['comment'], 'string', 'max' => 255]
|
||||
[['comment'], 'string', 'max' => 255],
|
||||
/////////////////////
|
||||
//cart
|
||||
/////////////////////
|
||||
[['cart'], 'string', 'max' => 10]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -78,10 +87,39 @@ class TicketCreate extends Ticket{
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes){
|
||||
$this->addTransfer();
|
||||
$this->addToCart();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function addTransfer(){
|
||||
$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
|
||||
|
||||
$transfer->status = Transfer::STATUS_PAID;
|
||||
if ( isset($this->comment)){
|
||||
$transfer->comment = $this->comment;
|
||||
}
|
||||
$transfer->id_user = \Yii::$app->user->id;
|
||||
$transfer->save();
|
||||
$this->_transfer = $transfer;
|
||||
}
|
||||
|
||||
protected function addToCart(){
|
||||
if ( $this->isAddToCart()){
|
||||
$item = new UserSoldItem();
|
||||
$item->id_transfer = $this->_transfer->id_transfer;
|
||||
$item->id_user = \Yii::$app->user->id;
|
||||
$item->save(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function isAddToCart(){
|
||||
$result = false;
|
||||
if ( isset( $this->cart ) && $this->cart == 'add' ){
|
||||
$result = true;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user