add reception global word listener,allow delete transactions, allow delete account_state

This commit is contained in:
2015-12-31 15:42:28 +01:00
parent f59eadd8cc
commit 0b58f628ed
13 changed files with 178 additions and 9 deletions

View File

@@ -471,6 +471,32 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
return $status;
}
public function beforeDelete(){
parent::beforeDelete();
if ( $this->type == Transfer::TYPE_TICKET){
$ticket = $this->ticket;
if ( $ticket != null ){
$ticket->delete();
}
}else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT){
$mm = $this->moneyMovement;
$mm->delete();
}else if ($this->type == Transfer::TYPE_PRODUCT){
$sale = $this->sale;
$product = $this->product;
$product->stock = $product->stock + $this->count;
$product->save();
$sale->delete();
}
ShoppingCart::deleteAll(['id_transfer' =>$this->id_transfer]);
UserSoldItem::deleteAll(['id_transfer' =>$this->id_transfer]);
return true;
}
/**
* @param string $mode The mode to load
* Available modes