implement registration in backend

This commit is contained in:
Roland Schneider
2018-12-30 23:04:06 +01:00
parent b2bb210cee
commit e3b6bc08a7
32 changed files with 794 additions and 276 deletions

View File

@@ -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);;
}