implement registration in backend
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
namespace common\manager;
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Event;
|
||||
use common\models\EventRegistration;
|
||||
use common\models\Ticket;
|
||||
use yii\db\Query;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\web\ServerErrorHttpException;
|
||||
@@ -22,6 +25,8 @@ class EventRegistrationManager extends \yii\base\Object
|
||||
const NO_FREE_SEATS = 4;
|
||||
const EVENT_TYPE_NOT_FOUND = 5;
|
||||
const TICKET_INSUFFICIENT = 6;
|
||||
const UNKNOWN_ERROR = 7;
|
||||
const MAX_SEAT_COUNT_EXCEEDED = 8;
|
||||
|
||||
public static $STATES = [
|
||||
self::CARD_NOT_FOUND => "CARD_NOT_FOUND",
|
||||
@@ -30,6 +35,8 @@ class EventRegistrationManager extends \yii\base\Object
|
||||
self::NO_FREE_SEATS => "NO_FREE_SEATS",
|
||||
self::EVENT_TYPE_NOT_FOUND => "EVENT_TYPE_NOT_FOUND",
|
||||
self::TICKET_INSUFFICIENT => "TICKET_INSUFFICIENT",
|
||||
self::UNKNOWN_ERROR => "UNKNOWN_ERROR",
|
||||
self::MAX_SEAT_COUNT_EXCEEDED => "MAX_SEAT_COUNT_EXCEEDED",
|
||||
|
||||
|
||||
];
|
||||
@@ -39,6 +46,7 @@ class EventRegistrationManager extends \yii\base\Object
|
||||
* @throws NotFoundHttpException
|
||||
* @throws BadRequestHttpException
|
||||
* @throws ServerErrorHttpException
|
||||
* @throws \yii\web\HttpException
|
||||
*/
|
||||
public function registerCard($cardEventForm){
|
||||
|
||||
@@ -77,21 +85,85 @@ class EventRegistrationManager extends \yii\base\Object
|
||||
|
||||
$selectedTicket = $eventType->findTicketAllowingEventType($activeTickets);
|
||||
|
||||
|
||||
if ( !isset($selectedTicket) ){
|
||||
throw new NotFoundHttpException("Ticket not found", self::TICKET_INSUFFICIENT);
|
||||
}
|
||||
|
||||
if ( $selectedTicket->hasOpenReservationCount() ){
|
||||
$selectedTicket->consumeReservationCount(1);
|
||||
}
|
||||
$selectedTicket->save();
|
||||
|
||||
$registration = new EventRegistration();
|
||||
$registration->id_event = $event->id;
|
||||
$registration->id_card = $card->id_card;
|
||||
$registration->id_ticket = $selectedTicket->id_ticket;
|
||||
$registration->save(false);
|
||||
try{
|
||||
$registration->save(false);
|
||||
}catch (\Throwable $exception){
|
||||
throw new ServerErrorHttpException("Failed to save", self::UNKNOWN_ERROR);
|
||||
}
|
||||
|
||||
$cardEventForm->registration = $registration;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function createFindRegistrationsQuery($idEvent){
|
||||
$query = new Query();
|
||||
$query->select([
|
||||
"event_registration.id as event_registration_id",
|
||||
"event_registration.created_at as event_registration_created_at",
|
||||
"event_registration.canceled_at as event_registration_canceled_at",
|
||||
"card.number as card_number",
|
||||
"card.number as card_number",
|
||||
"customer.name as customer_name",
|
||||
"customer.email as customer_email",
|
||||
]);
|
||||
$query->from(EventRegistration::tableName());
|
||||
$query->innerJoin(Event::tableName(), "event_registration.id_event = event.id");
|
||||
$query->innerJoin(Card::tableName(), "event_registration.id_card = card.id_card");
|
||||
$query->innerJoin(Customer::tableName(), "customer.id_customer_card = card.id_card");
|
||||
$query->andWhere(["event_registration.id_event" => $idEvent ]);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $idRegistration
|
||||
* @return array|EventRegistration|\yii\db\ActiveRecord|null
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function loadRegistration($idRegistration) {
|
||||
|
||||
$registration = EventRegistration::find()->andWhere(['id' => $idRegistration ])->one();
|
||||
if ($registration == null) {
|
||||
throw new NotFoundHttpException('The requested registration does not exist.');
|
||||
}
|
||||
return $registration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \common\models\EventRegistration $registration
|
||||
* @throws ServerErrorHttpException
|
||||
*/
|
||||
public function cancelRegistration($registration){
|
||||
if ( isset($registration->canceled_at)){
|
||||
throw new ServerErrorHttpException('The registration is already canceled');
|
||||
}
|
||||
|
||||
$ticket = Ticket::findOne(['id' => $registration->id_ticket ]);
|
||||
|
||||
$ticket->restoreReservationCount(1);
|
||||
$ticket->save(false);
|
||||
|
||||
$registration->canceled_at = date('Y-m-d H:i:s' );
|
||||
$registration->save(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ return [
|
||||
'Inactive' => 'Inaktív',
|
||||
'Invalid account (inactive)!' => 'Érvénytelen kassza (inaktív)!',
|
||||
'Invalid account!' => 'Érvénytelen kassza!',
|
||||
'Max Usage Count' => 'Akalmak',
|
||||
'Max Usage Count' => 'Belépések száma (f. villa)',
|
||||
'Month' => 'Hónap',
|
||||
'Name' => 'Név',
|
||||
'Normal' => 'Normál',
|
||||
@@ -45,4 +45,5 @@ return [
|
||||
'Type' => 'Típus',
|
||||
'Update' => 'Módosítás',
|
||||
'Updated At' => 'Módosítás ideje',
|
||||
'Max Reservation Count' => 'Foglalások száma (csop. edzés)',
|
||||
];
|
||||
|
||||
@@ -32,5 +32,12 @@ return [
|
||||
'Id Room' => 'Terem',
|
||||
'Id Trainer' => 'Edző',
|
||||
'Id Event Type' => 'Esemény Típus',
|
||||
'Registration Count' => 'Résztvevők'
|
||||
'Registration Count' => 'Résztvevők',
|
||||
'Card Number' => 'Kártyaszám',
|
||||
'Customer Name' => 'Vendég Neve',
|
||||
'Customer Email' => 'Vendég E-Mail címe',
|
||||
'Canceled At' => 'Sztornó dátum, idő',
|
||||
'Register' => 'Regisztráció',
|
||||
'Event Registration Created At' => 'Regisztráció dátum, idő',
|
||||
|
||||
];
|
||||
@@ -18,6 +18,7 @@ class CardEventRegistrationForm extends \yii\base\Model
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['card_number'], 'required' ],
|
||||
[['card_number'], 'validateFormat' ]
|
||||
];
|
||||
}
|
||||
@@ -29,5 +30,15 @@ class CardEventRegistrationForm extends \yii\base\Model
|
||||
public function getIsNewRecord(){
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'card_number' => \Yii::t('event', 'Card Number'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -123,13 +123,20 @@ class Collection extends \common\models\BaseFitnessActiveRecord
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* */
|
||||
*
|
||||
* @param string $mode
|
||||
* @param $start
|
||||
* @param $end
|
||||
* @param $idUser
|
||||
* @param $types
|
||||
* @param $idAccount
|
||||
* @return Query
|
||||
*/
|
||||
public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$types,$idAccount){
|
||||
|
||||
|
||||
$query = new Query();
|
||||
|
||||
$query->innerJoin("account",'account.id_account = collection.id_account' );
|
||||
@@ -168,7 +175,7 @@ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$ty
|
||||
|
||||
}
|
||||
|
||||
public static function mkTotalsResultWithAllAvailableAccount($queryResult,$accounts,$accountMap,$idAccount){
|
||||
public static function mkTotalsResultWithAllAvailableAccount($queryResult,$accounts,$idAccount){
|
||||
|
||||
$totals = [];
|
||||
$totals['total'] = 0;
|
||||
@@ -228,7 +235,7 @@ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$ty
|
||||
public static function mkReceptionTotal( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap){
|
||||
$result = [];
|
||||
$queryResult = self::exTotalQuery('reception', $start, $end, $idUser, $types, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount);
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $idAccount);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class CollectionCreate extends \common\models\Collection
|
||||
if (parent::beforeSave($insert)) {
|
||||
$this->id_user = Yii::$app->user->id;
|
||||
$this->created_by = Yii::$app->user->id;
|
||||
$paidAt = Transfer::mkPaidAtTotals($this->timestampStart, $this->timestampEnd, $this->user->id, null, $this->account->id_account, $this->accounts, $this->accountMap);
|
||||
$paidAt = Transfer::mkPaidAtTotals($this->timestampStart, $this->timestampEnd, $this->user->id, null, $this->account->id_account, $this->accounts );
|
||||
$this->money = $paidAt['total'];
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -19,6 +19,7 @@ use common\components\Helper;
|
||||
* @property integer $part_count
|
||||
* @property integer $part_required
|
||||
* @property integer $id_ticket_type
|
||||
* @property integer $id_discount
|
||||
* @property string $expired_at
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
|
||||
@@ -18,7 +18,10 @@ use yii\helpers\ArrayHelper;
|
||||
* @property integer $seat_count
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property \common\models\EventType eventType
|
||||
* @property \common\models\EventType $eventType
|
||||
* @property \common\models\Trainer $trainer
|
||||
* @property \common\models\Room $room
|
||||
* @property \common\models\EventRegistration[] $eventRegistrations
|
||||
*/
|
||||
class Event extends \yii\db\ActiveRecord
|
||||
{
|
||||
@@ -45,7 +48,8 @@ class Event extends \yii\db\ActiveRecord
|
||||
return [
|
||||
[['startDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'],
|
||||
[['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'],
|
||||
[['id_trainer','id_room', 'id_event_type'], 'required'],
|
||||
[['id_trainer','id_room', 'id_event_type','seat_count'], 'required'],
|
||||
[['id_trainer','id_room', 'id_event_type','seat_count'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -72,6 +76,7 @@ class Event extends \yii\db\ActiveRecord
|
||||
'startDateString' => Yii::t('event', 'Start'),
|
||||
'endDateString' => Yii::t('event', 'End'),
|
||||
'status' => Yii::t('event', 'Status'),
|
||||
'seat_count' => Yii::t('event', 'Seat Count'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -127,13 +132,18 @@ class Event extends \yii\db\ActiveRecord
|
||||
* @return \common\models\EventRegistration[]|\yii\db\ActiveQuery
|
||||
*/
|
||||
public function getEventRegistrationCount(){
|
||||
return sizeof($this->getEventRegistrations());
|
||||
return sizeof($this->eventRegistrations);
|
||||
}
|
||||
|
||||
public function hasFreeSeats(){
|
||||
$registrationCount = $this->getEventRegistrations() ;
|
||||
$registrationCount = sizeof($this->eventRegistrations) ;
|
||||
|
||||
return $registrationCount < $this->seat_count ;
|
||||
$seatCount = $this->seat_count;
|
||||
if ( !isset($seatCount ) || $seatCount == 0){
|
||||
$seatCount = PHP_INT_MAX;
|
||||
}
|
||||
|
||||
return $registrationCount < $seatCount ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* This is the model class for table "event_registration".
|
||||
@@ -50,4 +52,15 @@ class EventRegistration extends \yii\db\ActiveRecord
|
||||
'canceled_at' => Yii::t('event-registration', 'Canceled At'),
|
||||
];
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return ArrayHelper::merge( [
|
||||
[
|
||||
'class' => TimestampBehavior::className(),
|
||||
'value' => function(){ return date('Y-m-d H:i:s' ); }
|
||||
]
|
||||
],
|
||||
parent::behaviors());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,19 @@ class EventType extends \yii\db\ActiveRecord
|
||||
if ( sizeof($tickets) == 0 ){
|
||||
return null;
|
||||
}
|
||||
$possibleTickets = [];
|
||||
|
||||
foreach ($tickets as $ticket ){
|
||||
if ( $ticket->hasOpenReservationCount() ){
|
||||
$possibleTickets[] = $ticket;
|
||||
}
|
||||
}
|
||||
|
||||
if ( sizeof($possibleTickets) == 0 ){
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: implement bossiness logic to select ticket
|
||||
return $tickets[0];
|
||||
return $possibleTickets[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);;
|
||||
}
|
||||
|
||||
@@ -24,13 +24,22 @@ use yii\helpers\ArrayHelper;
|
||||
* @property integer door_allowed
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property integer $max_reservation_count
|
||||
* @property \common\models\Account $account
|
||||
* @property string $typeHuman
|
||||
* @property string $timeUnitHuman
|
||||
* @property string $accountName
|
||||
*/
|
||||
class TicketType extends \common\models\BaseFitnessActiveRecord {
|
||||
class TicketType extends BaseFitnessActiveRecord
|
||||
{
|
||||
const STATUS_DELETED = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
CONST TIME_UNIT_DAY = 10;//nap
|
||||
CONST TIME_UNIT_MONTH = 20;//hónap
|
||||
CONST TIME_UNIT_MONTH_REFERENCE = 30; //tárgy hónap
|
||||
// day
|
||||
CONST TIME_UNIT_DAY = 10;
|
||||
// month
|
||||
CONST TIME_UNIT_MONTH = 20;
|
||||
// subject month
|
||||
CONST TIME_UNIT_MONTH_REFERENCE = 30;
|
||||
const TYPE_NORMAL = 10;
|
||||
const TYPE_DEFAULT = self::TYPE_NORMAL;
|
||||
|
||||
@@ -57,7 +66,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'id_account','time_unit_count','type' ,'time_unit_type' ,'max_usage_count','price_brutto'], 'required'],
|
||||
[['name', 'id_account','time_unit_count','type' ,'time_unit_type' ,'max_usage_count','max_reservation_count','price_brutto'], 'required'],
|
||||
////////////////
|
||||
//price brutto
|
||||
////////////////
|
||||
@@ -76,6 +85,10 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
|
||||
////////////////
|
||||
[['max_usage_count',], 'integer','min' => 0 , 'max' => 10000],
|
||||
////////////////
|
||||
//max_reservation_count
|
||||
////////////////
|
||||
[['max_reservation_count',], 'integer','min' => 0 , 'max' => 10000],
|
||||
////////////////
|
||||
//flag_student
|
||||
////////////////
|
||||
[['flag_student',], 'integer'],
|
||||
@@ -140,6 +153,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
|
||||
'installment_count' => Yii::t('common/ticket_type', 'Havi részletek száma'),
|
||||
'installment_money' => Yii::t('common/ticket_type', 'Havi részlet összege'),
|
||||
'door_allowed' => Yii::t('common/ticket_type', 'Forgóvilla'),
|
||||
'max_reservation_count' => Yii::t('common/ticket_type', 'Max Reservation Count'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -169,7 +183,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
|
||||
}
|
||||
public function getTimeUnitHuman() {
|
||||
$result = null;
|
||||
$s = self::timeUnitTypes ( $this->time_unit_type );
|
||||
$s = self::timeUnitTypes( );
|
||||
if (array_key_exists ( $this->time_unit_type, $s )) {
|
||||
$result = $s [$this->time_unit_type];
|
||||
}
|
||||
@@ -210,7 +224,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
|
||||
}
|
||||
|
||||
|
||||
public function validateIdAccount($attribute,$params){
|
||||
public function validateIdAccount($attribute){
|
||||
$account = null;
|
||||
if ( !$this->hasErrors("id_account")){
|
||||
$account = Account::findOne($this->$attribute);
|
||||
@@ -233,9 +247,12 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive
|
||||
* */
|
||||
/**
|
||||
* $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive
|
||||
* @param null $forceIncludeObjectWithId
|
||||
* @param null $account
|
||||
* @return array|\yii\db\ActiveRecord[]|null
|
||||
*/
|
||||
public static function read($forceIncludeObjectWithId = null, $account = null){
|
||||
$ticketTypes = null;
|
||||
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Object;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use common\components\AccountAwareBehavior;
|
||||
use common\components\UserAwareBehavior;
|
||||
use common\components\DiscountAwareBehavior;
|
||||
use common\components\CustomerAwareBehavior;
|
||||
use yii\db\Query;
|
||||
@@ -604,12 +601,17 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
public function beforeDelete() {
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \yii\db\StaleObjectException
|
||||
*/
|
||||
public function beforeDelete() {
|
||||
parent::beforeDelete ();
|
||||
if ($this->type == Transfer::TYPE_TICKET) {
|
||||
$ticket = $this->ticket;
|
||||
if ($ticket != null) {
|
||||
$ticket->delete ();
|
||||
$ticket->delete();
|
||||
}
|
||||
} else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
||||
/** @noinspection PhpUndefinedFieldInspection */
|
||||
@@ -816,11 +818,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
* an array, wchic contains items. each item has to key - value pairs: [ id_account => 0, money => 0 ]
|
||||
*
|
||||
* @param $accounts
|
||||
* @param $accountMap
|
||||
* @param $idAccount
|
||||
* @return array
|
||||
*/
|
||||
public static function mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount) {
|
||||
public static function mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $idAccount) {
|
||||
$totals = [ ];
|
||||
$totals ['total'] = 0;
|
||||
|
||||
@@ -867,6 +868,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
* @param $types
|
||||
* @param $idAccount
|
||||
* @return array
|
||||
* @throws \yii\db\Exception
|
||||
*/
|
||||
public static function exTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) {
|
||||
$query = self::mkTotalQuery ( $mode, $start, $end, $idUser, $types, $idAccount );
|
||||
@@ -885,45 +887,56 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
* @param $accounts
|
||||
* @param $accountMap
|
||||
* @return array
|
||||
* @throws \yii\db\Exception
|
||||
*/
|
||||
public static function mkPaidAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||
public static function mkPaidAtTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$result = [ ];
|
||||
$queryResult = self::exTotalQuery ( 'paid_at', $start, $end, $idUser, $types, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* find all transfers in the period ( doesn't matter if paid or not )
|
||||
*/
|
||||
public static function mkCreatedAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||
|
||||
/**
|
||||
* find all transfers in the period ( doesn't matter if paid or not )
|
||||
* @throws \yii\db\Exception
|
||||
*/
|
||||
public static function mkCreatedAtTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$result = [ ];
|
||||
$queryResult = self::exTotalQuery ( 'created_at', $start, $end, $idUser, $types, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* find transfers which were created but not paid in the period
|
||||
*/
|
||||
public static function mkCreatedAtNotPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||
|
||||
/**
|
||||
* find transfers which were created but not paid in the period
|
||||
* @throws \yii\db\Exception
|
||||
*/
|
||||
public static function mkCreatedAtNotPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$result = [ ];
|
||||
$queryResult = self::exTotalQuery ( 'created_at_not_paid', $start, $end, $idUser, $types, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* find transfers which were created and paid in the period
|
||||
*/
|
||||
public static function mkCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||
|
||||
/**
|
||||
* find transfers which were created and paid in the period
|
||||
* @param $start
|
||||
* @param $end
|
||||
* @param $idUser
|
||||
* @param $types
|
||||
* @param $idAccount
|
||||
* @param $accounts
|
||||
* @return array
|
||||
* @throws \yii\db\Exception
|
||||
*/
|
||||
public static function mkCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$result = [ ];
|
||||
$queryResult = self::exTotalQuery ( 'created_at_paid', $start, $end, $idUser, $types, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -937,22 +950,35 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
* @param $accounts
|
||||
* @param $accountMap
|
||||
* @return array
|
||||
* @throws \yii\db\Exception
|
||||
*/
|
||||
public static function mkPaidAtNotCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||
public static function mkPaidAtNotCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$result = [ ];
|
||||
$queryResult = self::exTotalQuery ( 'paid_at_not_created_at', $start, $end, $idUser, $types, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
|
||||
return $result;
|
||||
}
|
||||
public static function mkTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||
|
||||
/**
|
||||
* @param $start
|
||||
* @param $end
|
||||
* @param $idUser
|
||||
* @param $types
|
||||
* @param $idAccount
|
||||
* @param $accounts
|
||||
* @param $accountMap
|
||||
* @return array
|
||||
* @throws \yii\db\Exception
|
||||
*/
|
||||
public static function mkTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
|
||||
$result = [ ];
|
||||
|
||||
$result ['paid_at'] = self::mkPaidAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
|
||||
$result ['created_at'] = self::mkCreatedAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
|
||||
$result ['created_at_not_paid'] = self::mkCreatedAtNotPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
|
||||
$result ['created_at_paid'] = self::mkCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
|
||||
$result ['paid_at_not_created_at'] = self::mkPaidAtNotCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
|
||||
$result ['paid_at'] = self::mkPaidAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
|
||||
$result ['created_at'] = self::mkCreatedAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
|
||||
$result ['created_at_not_paid'] = self::mkCreatedAtNotPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
|
||||
$result ['created_at_paid'] = self::mkCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
|
||||
$result ['paid_at_not_created_at'] = self::mkPaidAtNotCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -1220,6 +1246,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
$ticket->id_discount = null; // contract.id_discount
|
||||
$ticket->start = $request->request_target_time_at;
|
||||
$ticket->end = date ( 'Y-m-d', strtotime ( $request->request_target_time_at . " +1 month -1 day" ) );
|
||||
$ticket->max_reservation_count = $ticketType->max_reservation_count;
|
||||
$ticket->max_usage_count = $ticketType->max_usage_count;
|
||||
$ticket->usage_count = 0;
|
||||
$ticket->status = Ticket::STATUS_INACTIVE;
|
||||
|
||||
Reference in New Issue
Block a user