implement registration in backend
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use common\manager\EventRegistrationManager;
|
||||
use Yii;
|
||||
use yii\db\Query;
|
||||
use yii\db\Expression;
|
||||
use common\components\Helper;
|
||||
use yii\web\HttpException;
|
||||
|
||||
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
||||
|
||||
@@ -33,6 +35,8 @@ use common\components\Helper;
|
||||
* @property int id_contract
|
||||
* @property integer $original_price
|
||||
* @property string $original_end;
|
||||
* @property integer $reservation_count
|
||||
* @property integer $max_reservation_count
|
||||
*
|
||||
* @property \common\models\Card card
|
||||
* @property \common\models\Ticket transfer
|
||||
@@ -441,7 +445,31 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function hasOpenReservationCount(){
|
||||
return $this->reservation_count < $this->max_reservation_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $count
|
||||
* @throws HttpException
|
||||
*/
|
||||
public function consumeReservationCount($count){
|
||||
$newReservationCount = $this->reservation_count + $count;
|
||||
if ( $newReservationCount > $this->max_reservation_count ){
|
||||
throw new HttpException(406,"Max ticket seat count exceeded",EventRegistrationManager::MAX_SEAT_COUNT_EXCEEDED);
|
||||
}
|
||||
$this->reservation_count = $newReservationCount;
|
||||
}
|
||||
|
||||
public function restoreReservationCount($usagesToRestore){
|
||||
$this->reservation_count = $this->reservation_count - $usagesToRestore;
|
||||
if ( $this->usage_count < 0 ){
|
||||
$this->usage_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function afterSave($insert, $changedAttributes) {
|
||||
Card::updateCardFlagTicket($this->id_card);;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user