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

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