user auto disable word listening
improve card creation mobileapi - add ticket usage count
This commit is contained in:
@@ -28,17 +28,17 @@ class TicketCreate extends Ticket{
|
||||
public $_discount;
|
||||
public $_transfer;
|
||||
public $_ticketType;
|
||||
|
||||
|
||||
|
||||
|
||||
public $customer;
|
||||
public $userCart;
|
||||
public $customerCart;
|
||||
|
||||
|
||||
|
||||
|
||||
public $cart;
|
||||
|
||||
|
||||
public $payment_method;
|
||||
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
@@ -75,7 +75,7 @@ class TicketCreate extends Ticket{
|
||||
[[ 'max_usage_count'], 'required'],
|
||||
[[ 'max_usage_count'], 'integer'],
|
||||
/////////////////////
|
||||
//price
|
||||
//price
|
||||
/////////////////////
|
||||
[[ 'price_brutto'], 'required'],
|
||||
[[ 'price_brutto'], 'integer'],
|
||||
@@ -87,11 +87,11 @@ class TicketCreate extends Ticket{
|
||||
//cart
|
||||
/////////////////////
|
||||
[['cart'], 'string', 'max' => 10]
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function validateTicketType($attribute){
|
||||
$type = TicketType::findOne($this->id_ticket_type);
|
||||
$this->_ticketType = $type;
|
||||
@@ -114,40 +114,40 @@ class TicketCreate extends Ticket{
|
||||
$query->andWhere( [ '>', 'expired_at' , Helper::getDateTimeString() ]);
|
||||
$query->andWhere( [ 'not in', 'flag', [Contract::$FLAG_DELETED ] ]);
|
||||
$contracts = $query->all();
|
||||
|
||||
|
||||
if ( count($contracts) > 0 ){
|
||||
$this->addError($attribute,"A vendégnek már van érvényes vagy felbontott szerződése!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function validateAccount($attribute){
|
||||
$this->_account = Account::findOne($this->id_account);
|
||||
if ( !isset($this->_account )) {
|
||||
$this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid transfer' ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function validateDiscount($attribute){
|
||||
$this->_discount = Discount::findOne($this->id_discount);
|
||||
if ( !isset($this->_discount)) {
|
||||
$this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid discount' ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function beforeSave($insert){
|
||||
$result = parent::beforeSave($insert);
|
||||
if ( $result ){
|
||||
if ($insert){
|
||||
|
||||
|
||||
if ( $this->isAppendToCustomerCart() || $this->isAppendToUserCart()){
|
||||
$this->status = Ticket::STATUS_INACTIVE;
|
||||
}else{
|
||||
$this->status = Ticket::STATUS_ACTIVE;
|
||||
}
|
||||
|
||||
|
||||
$ticketType = TicketType::findOne($this->id_ticket_type);
|
||||
if ( isset($ticketType) && $ticketType->isInstallment() ){
|
||||
$this->part = 0;
|
||||
@@ -157,12 +157,17 @@ class TicketCreate extends Ticket{
|
||||
$this->part_count = 0;
|
||||
}
|
||||
|
||||
if ( isset($ticketType )){
|
||||
$this->original_price = $ticketType->price_brutto;
|
||||
if (isset($ticketType)) {
|
||||
$this->original_price = $ticketType->price_brutto;
|
||||
$start = DateUtil::parseDate($this->start);
|
||||
$original_end = Helper::getTicketExpirationDate($start,$ticketType);
|
||||
$this->original_end = DateUtil::formatDateUtc($original_end);
|
||||
$this->max_reservation_count = $ticketType->max_reservation_count;
|
||||
$original_end = Helper::getTicketExpirationDate($start, $ticketType);
|
||||
$this->original_end = DateUtil::formatDateUtc($original_end);
|
||||
$this->max_reservation_count = $ticketType->max_reservation_count;
|
||||
|
||||
if (!Helper::isTicketCreatePriceEditable()) {
|
||||
$this->price_brutto = $ticketType->price_brutto;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,18 +185,18 @@ class TicketCreate extends Ticket{
|
||||
$this->appendToCustomerCart();
|
||||
$this->addContract($insert);
|
||||
$this->updateCardFlag();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function updateCardFlag(){
|
||||
Card::updateCardFlagTicket($this->id_card);
|
||||
}
|
||||
|
||||
|
||||
public function addContract($insert){
|
||||
if ($insert){
|
||||
$ticketType = TicketType::findOne($this->id_ticket_type);
|
||||
if ( isset($ticketType) && $ticketType->isInstallment() ){
|
||||
|
||||
|
||||
$contract = new Contract();
|
||||
$contract->id_customer = $this->customer->id_customer;
|
||||
$contract->id_user = \Yii::$app->user->id;
|
||||
@@ -204,7 +209,7 @@ class TicketCreate extends Ticket{
|
||||
$contract->id_ticket_type = $this->id_ticket_type;
|
||||
$contract->id_discount = $this->id_discount;
|
||||
$contract->save();
|
||||
|
||||
|
||||
$requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer,$contract);
|
||||
foreach ($requests as $request){
|
||||
$request->save(false);
|
||||
@@ -219,24 +224,27 @@ class TicketCreate extends Ticket{
|
||||
protected function addTransfer(){
|
||||
//$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
|
||||
|
||||
|
||||
|
||||
$transfer = new Transfer();
|
||||
|
||||
|
||||
$transfer->type = Transfer::TYPE_TICKET;
|
||||
$transfer->direction = Transfer::DIRECTION_IN;
|
||||
|
||||
|
||||
$transfer->id_object = $this->id_ticket;
|
||||
|
||||
|
||||
$transfer->item_price = $this->_ticketType->price_brutto;
|
||||
$transfer->count = 1;
|
||||
|
||||
|
||||
if (isset ( $this->_discount )) {
|
||||
$transfer->id_discount = $this->_discount->id_discount;
|
||||
}
|
||||
|
||||
|
||||
$transfer->money = $this->price_brutto;
|
||||
|
||||
|
||||
if ( Helper::isTicketCreatePriceEditable() ){
|
||||
$transfer->money = $this->price_brutto;
|
||||
} else {
|
||||
$transfer->money = $transfer->item_price;
|
||||
}
|
||||
|
||||
$transfer->id_account = $this->_account->id_account;
|
||||
|
||||
if ( !Transfer::canMarkPaidByReception( $this->payment_method ) ){
|
||||
@@ -252,7 +260,7 @@ class TicketCreate extends Ticket{
|
||||
}
|
||||
$transfer->status = $status;
|
||||
$transfer->payment_method = $this->payment_method;
|
||||
|
||||
|
||||
if ( isset($this->comment)){
|
||||
$transfer->comment = $this->comment;
|
||||
}
|
||||
@@ -264,7 +272,7 @@ class TicketCreate extends Ticket{
|
||||
}
|
||||
$this->_transfer = $transfer;
|
||||
}
|
||||
|
||||
|
||||
public function isAppendToUserCart(){
|
||||
$result = false;
|
||||
if ( isset( $this->cart ) && $this->cart == 'user' ){
|
||||
@@ -272,7 +280,7 @@ class TicketCreate extends Ticket{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function isAppendToCustomerCart(){
|
||||
$result = false;
|
||||
if ( isset( $this->cart ) && $this->cart == 'customer' ){
|
||||
@@ -310,11 +318,11 @@ class TicketCreate extends Ticket{
|
||||
\Yii::error("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
|
||||
throw new \Exception("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user