add contract

This commit is contained in:
2016-01-25 01:43:19 +01:00
parent fd4d38ab44
commit df14401b28
47 changed files with 2868 additions and 766 deletions

View File

@@ -12,6 +12,8 @@ use common\models\CardSearch;
use common\models\AccountState;
use common\models\Key;
use common\models\CardKeyAssignment;
use common\models\Contract;
use yii\db\Expression;
/**
* ContactForm is the model behind the contact form.
@@ -26,6 +28,7 @@ class ReceptionForm extends Model
public $cardSearchModel;
public $lastCassaState;
public $keys;
public $contract;
/**
* @inheritdoc
*/
@@ -73,6 +76,7 @@ class ReceptionForm extends Model
$this->customer = $this->card->customer;
$this->readValidTickets();
$this->readAssignedKeys();
$this->readContract();
}
$defaultAccount = Account::readDefault();
@@ -104,6 +108,18 @@ class ReceptionForm extends Model
}
}
public function readContract(){
if ($this->isCardWithCustomer()){
$query = Contract::find();
$query->andWhere(['id_customer' => $this->customer->id_customer ]);
$query->andWhere([ '>=' ,'expired_at' , new Expression("now()") ]);
$query->andWhere(["not in" , 'flag' , [Contract::$FLAG_DELETED, Contract::$FLAG_CANCELED]]);
$this->contract = $query->one();
}
}
public function hasCassa(){
return isset($this->lastCassaState) ;
}