add contract
This commit is contained in:
@@ -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) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user