add display money to account state close, delete ticket on customer tickets

This commit is contained in:
2016-01-10 15:25:25 +01:00
parent 5a98d128bc
commit 7c584a0779
21 changed files with 291 additions and 19 deletions

View File

@@ -9,6 +9,7 @@ use common\models\Customer;
use common\models\Ticket;
use common\models\Account;
use common\models\CardSearch;
use common\models\AccountState;
/**
* ContactForm is the model behind the contact form.
@@ -21,6 +22,7 @@ class ReceptionForm extends Model
public $tickets;
public $defaultAccount;
public $cardSearchModel;
public $lastCassaState;
/**
* @inheritdoc
@@ -58,10 +60,33 @@ class ReceptionForm extends Model
$this->defaultAccount = Account::findOne($defaultAccount);
}
$this->readLastCassaState();
$this->cardSearchModel = new CardSearch();
}
public function readLastCassaState(){
$a = Account::readDefault();
if ( isset($a)){
$this->lastCassaState = AccountState::find()->andWhere(['account_state.id_account' => $a])
->andWhere(['account_state.id_user' => \Yii::$app->user->id] )
->orderBy(['account_state.created_at' => SORT_DESC])
->limit(1)
->one();
}
}
public function hasCassa(){
return isset($this->lastCassaState) ;
}
public function isCassaOpen(){
return ( isset($this->lastCassaState) && $this->lastCassaState->isTypeOpen());
}
public function isCassaClose(){
return ( isset($this->lastCassaState) && $this->lastCassaState->isTypeClose());
}
public function getDefaultAccountName(){
$result = "";
if ( $this->defaultAccount ){