/** @inheritdoc */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if (!isset($changedAttributes['Money'])) { return; } $diff = $this->Money - $changedAttributes['Money']; Yii::warning('Изменен баланс ' . \yii\helpers\Html::a('№' . $this->PersonID . ' ' . $this->person->getFullName(true), ['/user/admin/update', 'id' => $this->PersonID]) . ' на ' . ($diff > 0 ? '+' : '') . $diff, 'info'); if ($diff > 0) { $levels = LevelsRecord::getAvailable(); /** @var LevelsRecord $level */ foreach ($levels as $level) { /** @var LevelsRecord $level */ if ($level->StartLevel || $level->id == $this->LevelID) { continue; } //Yii::warning('Проверка уровня ' . $level->Name . ': $level->OneCheckCharge ' . $level->OneCheckCharge . '/ $level->Charge ' . $level->Charge, 'info'); if ($level->PersonsExpression == LevelsRecord::TYPE_CHARGE && $diff >= $level->OneCheckCharge) { Yii::warning('Переход на следующий ' . \yii\helpers\Html::a('уровень (' . $level->Name . ')', ['/levels/index']) . ' по пополнению - №' . \yii\helpers\Html::a($this->person->getFullName(true), ['/user/admin/update', 'id' => $this->PersonID]), 'info'); return $this->updateAttributes(['LevelID' => $level->ID]); } else { if ($level->PersonsExpression == LevelsRecord::TYPE_SPEND && $this->Spend >= $level->Charge) { Yii::warning('Переход на следующий ' . \yii\helpers\Html::a('уровень (' . $level->Name . ')', ['/levels/index']) . ' по накоплению средств - №' . \yii\helpers\Html::a($this->person->getFullName(true), ['/user/admin/update', 'id' => $this->PersonID]), 'info'); return $this->updateAttributes(['LevelID' => $level->ID]); } } } } }
</strong> <?php } else { ?> <i class="fa fa-fw fa-money"></i> Счет <strong class="pull-right"><i class="fa fa-fw fa-lock" aria-hidden="true"></i> заблокирован</strong> <?php } ?> </h2> </div> <!-- <div class="panel-body"></div>--> <?php if ($user->account) { ?> <?php echo DetailView::widget(['model' => $user->account, 'attributes' => [['label' => 'Деньги:', 'value' => ''], ['attribute' => 'Money', 'format' => 'raw', 'value' => Yii::$app->formatter->asCurrency($user->account->Money) . ($user->account->InPawn > 0 ? ' <small>+ залог ' . Yii::$app->formatter->asCurrency($user->account->InPawn) . '</small>' : '')], 'Spend:currency', 'Charged:currency', ['label' => 'Бонусы:', 'value' => ''], 'Bonuses:currency', 'SpendBonuses:currency', 'ChargedBonuses:currency', ['attribute' => 'person.group.Name', 'visible' => !Yii::$app->user->identity->ServiceCard], ['attribute' => 'person.group.Name', 'visible' => Yii::$app->user->identity->ServiceCard, 'format' => 'raw', 'value' => Editable::widget(['model' => $user, 'name' => 'GroupID', 'attribute' => 'GroupID', 'displayValueConfig' => ArrayHelper::map(\common\models\cf\PersonsGroupRecord::findAll(['Deleted' => 0]), 'ID', 'Name'), 'asPopover' => true, 'header' => Yii::t('models', 'Group Name'), 'format' => Editable::FORMAT_BUTTON, 'inputType' => Editable::INPUT_DROPDOWN_LIST, 'data' => ArrayHelper::map(\common\models\cf\PersonsGroupRecord::findAll(['Deleted' => 0]), 'ID', 'Name'), 'options' => ['class' => 'form-control', 'prompt' => 'Выберите группу...'], 'editableValueOptions' => ['class' => 'text-danger'], 'formOptions' => ['action' => ['/user/admin/editable', 'id' => $user->id]]])], ['attribute' => 'level.Name', 'value' => $user->account->level->Name . ' (' . $user->account->level->Discount . '%)', 'visible' => !Yii::$app->user->identity->ServiceCard], ['visible' => Yii::$app->user->identity->ServiceCard, 'attribute' => 'level.Name', 'format' => 'raw', 'value' => Editable::widget(['model' => $user->account, 'name' => 'LevelID', 'attribute' => 'LevelID', 'displayValueConfig' => ArrayHelper::map(\common\models\cf\LevelsRecord::getAvailable(), 'ID', 'Name'), 'asPopover' => true, 'header' => Yii::t('models', 'Level Name'), 'format' => Editable::FORMAT_BUTTON, 'inputType' => Editable::INPUT_DROPDOWN_LIST, 'data' => ArrayHelper::map(\common\models\cf\LevelsRecord::getAvailable(), 'ID', 'Name'), 'options' => ['class' => 'form-control', 'prompt' => 'Выберите уровень...'], 'editableValueOptions' => ['class' => 'text-danger'], 'formOptions' => ['action' => ['/user/admin/editable-level', 'id' => $user->id]]])]]]); ?> <?php } ?> <ul class="list-group"> <?php if (Yii::$app->user->can('/accounts/charge-balance')) { ?> <li class="list-group-item"> <?php echo ButtonLink::widget(['label' => '<i class="fa fa-fw fa-plus" aria-hidden="true"></i> ' . Yii::t('app', 'Charge balance') . ' (мин.' . Yii::$app->formatter->asCurrency($user->group->MinMoneyToEmit) . ')', 'encodeLabel' => false, 'type' => 'primary', 'url' => ['/accounts/charge-balance', 'id' => $user->account->id], 'options' => ['class' => 'btn-block', 'id' => 'charge-button']]); ?> </li> <?php }