add ticket installment
This commit is contained in:
@@ -83,6 +83,7 @@ class TicketCreate extends Ticket{
|
||||
//cart
|
||||
/////////////////////
|
||||
[['cart'], 'string', 'max' => 10]
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -91,6 +92,18 @@ class TicketCreate extends Ticket{
|
||||
$type = TicketType::findOne($this->id_ticket_type);
|
||||
if ( !isset($type)) {
|
||||
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid ticket type' ));
|
||||
}else{
|
||||
if ( $type->isInstallment()){
|
||||
$bankAccount = trim($this->customer->bank_account);
|
||||
if ( !isset($bankAccount) || empty($bankAccount)){
|
||||
$this->addError($attribute,"Nincs bankszámlaszám vagy érvénytelen");
|
||||
return;
|
||||
}
|
||||
if ( !( strlen($bankAccount) == 16 || strlen($bankAccount) == 24 ) ){
|
||||
$this->addError($attribute,"Vendég bankszámlaszáma nem 16 vagy 24 hosszú");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +121,23 @@ class TicketCreate extends Ticket{
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeSave($insert){
|
||||
$result = parent::beforeSave($insert);
|
||||
if ( $result ){
|
||||
if ($insert){
|
||||
$ticketType = TicketType::findOne($this->id_ticket_type);
|
||||
if ( isset($ticketType) && $ticketType->isInstallment() ){
|
||||
$this->part = 0;
|
||||
$this->part_paid = 0;
|
||||
$this->part_count = $ticketType->installment_count;
|
||||
}else{
|
||||
$this->part_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes){
|
||||
$this->addTransfer();
|
||||
$this->appendToUserCart();
|
||||
|
||||
Reference in New Issue
Block a user