/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PersonsGroupRecord::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['ID' => $this->ID, 'CardDeposit' => $this->CardDeposit, 'EmitCardCost' => $this->EmitCardCost, 'MinMoneyToEmit' => $this->MinMoneyToEmit, 'Deleted' => $this->Deleted, 'CardRepairCost' => $this->CardRepairCost, 'IsService' => $this->IsService, 'IsGift' => $this->IsGift]);
     $query->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'Description', $this->Description]);
     return $dataProvider;
 }
 /**
  * Step 3
  * @param $hardId
  * @return string|\yii\web\Response
  * @throws HttpException
  */
 public function actionCreateAccount($hardId, $groupId = '')
 {
     /** @var PersonsGroupRecord $group */
     if ($groupId !== '') {
         $group = PersonsGroupRecord::findOne($groupId);
     } else {
         $group = PersonsGroupRecord::getDefault();
     }
     /** @var PersonsRecord $user */
     $user = Yii::createObject(['class' => PersonsRecord::className(), 'scenario' => 'create']);
     /** @var CardForm $card */
     $card = \Yii::createObject(CardForm::className());
     $card->HardID = $hardId;
     if (!$card->isExist()) {
         $card = $card->create();
     } else {
         $card = $card->find();
     }
     if (!$card->ID) {
         throw new HttpException(400, 'Не удалось сохранить номер карты');
     }
     $user->CardID = $card->id;
     $user->GroupID = $group->id;
     $user->ServiceCard = $group->IsService;
     $this->performAjaxValidation($user);
     if ($user->load(Yii::$app->request->post()) && $user->create()) {
         /** @var FinanceRecord $finance */
         $finance = Yii::createObject(FinanceRecord::className());
         $finance->ClassID = 2;
         //Регистраци карты
         $finance->ContractorID = $user->ID;
         $finance->save();
         Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been created'));
         return $this->redirect(['/accounts/charge-balance', 'id' => $user->account->id]);
     }
     return $this->render('createAccount', ['user' => $user]);
 }
 /**
  * Finds the Assignment model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param  integer $id
  * @return Assignment the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PersonsGroupRecord::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionCreateAccount($hardId, $groupId = '')
 {
     /** @var PersonsGroupRecord $group */
     if ($groupId !== '') {
         $group = PersonsGroupRecord::findOne($groupId);
     } else {
         $group = PersonsGroupRecord::getDefault();
     }
     /** @var PersonsRecord $user */
     $user = Yii::$app->user->identity;
     if ($group->ID < $user->GroupID) {
         throw new ForbiddenHttpException('Вы не можете зарегистрировать карту более высокого уровня');
     }
     /** @var PersonsRecord $user */
     $user = Yii::createObject(['class' => PersonsRecord::className(), 'scenario' => 'create']);
     $user->GroupID = $group->id;
     $user->ServiceCard = $group->IsService;
     //from parent controller (not my behavior)
     $this->performAjaxValidation($user);
     //data already loaded with ajax validation
     if ($user->load(Yii::$app->request->post()) && $user->validate()) {
         $card = null;
         /** @var CardForm $card */
         $cardForm = \Yii::createObject(CardForm::className());
         $cardForm->HardID = $hardId;
         if (!$cardForm->isExist()) {
             $card = $cardForm->create();
         } else {
             if ($cardForm->isUsed()) {
                 throw new HttpException(400, 'Данная карта уже зарегистрирована в системе');
             } else {
                 $card = $cardForm->find();
             }
         }
         if (!$card->ID) {
             throw new HttpException(400, 'Не удалось зарегистрировать карту');
         }
         $user->CardID = $card->id;
         if ($user->create()) {
             /** @var FinanceRecord $finance */
             $finance = Yii::createObject(FinanceRecord::className());
             $finance->ClassID = 2;
             //Регистраци карты
             $finance->ContractorID = $user->ID;
             $finance->save();
             //Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been created'));
             return $this->redirect(['/person/children', 'personId' => $user->id]);
         }
     }
     return $this->render('createAccount', ['user' => $user]);
 }
Esempio n. 5
0
</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 
}
Esempio n. 6
0
 public function getGroup()
 {
     return $this->hasOne(PersonsGroupRecord::className(), ['ID' => 'GroupID']);
 }
Esempio n. 7
0
use yii\data\ActiveDataProvider;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\jui\DatePicker;
use yii\web\View;
use yii\widgets\Pjax;
use kartik\export\ExportMenu;
use kartik\grid\GridView as KartikGridView;
/**
 * @var View $this
 * @var ActiveDataProvider $dataProvider
 * @var UserSearch $searchModel
 */
$this->title = Yii::t('user', 'Manage users');
$this->params['breadcrumbs'][] = $this->title;
$gridColumns = [['attribute' => 'group.Name', 'filter' => \common\models\cf\PersonsGroupRecord::find()->select(['Name'])->indexBy('Name')->column(), 'options' => ['style' => 'width: 1%'], 'group' => true], ['attribute' => 'accountLevelID', 'header' => 'Уровень', 'filter' => \common\models\cf\LevelsRecord::find()->select(['Name'])->indexBy('ID')->column(), 'value' => function ($model) {
    if ($model->account && $model->account->level) {
        return $model->account->level->Name;
    } else {
        return '';
    }
}, 'options' => ['style' => 'width: 1%'], 'group' => true], ['attribute' => 'ID', 'format' => 'raw', 'value' => function ($model) {
    return $model->id . ':' . $model->account->id;
}, 'options' => ['style' => 'width: 1%']], ['attribute' => 'card.HardID', 'header' => '№ карты', 'format' => 'raw', 'value' => function ($model) {
    return $model->card ? $model->card->id . ': ' . $model->card->HardID : 'без карты';
}, 'options' => ['style' => 'width: 1%']], ['attribute' => 'searchName', 'header' => 'Имя', 'format' => 'raw', 'value' => function ($model) {
    return $model->fullName;
}], ['attribute' => 'childrenCount'], ['attribute' => 'IsRegularClient', 'visible' => $searchModel->hasAttribute('IsRegularClient'), 'class' => \common\components\BooleanFilterColumn::className()], 'Phone1', 'account.Money:currency', 'account.Spend:currency', ['attribute' => 'ServiceCard', 'class' => \common\components\BooleanFilterColumn::className()], ['attribute' => 'Deleted', 'class' => \common\components\BooleanFilterColumn::className()], ['attribute' => 'RegisterDate', 'format' => 'dateTime', 'filter' => \kartik\daterange\DateRangePicker::widget(['model' => $searchModel, 'attribute' => 'RegisterDate', 'presetDropdown' => true, 'hideInput' => true, 'pluginOptions' => ['locale' => ['format' => 'DD.MM.YYYY HH:mm']]])], ['header' => Yii::t('user', 'Block status'), 'stateAttribute' => 'Blocked', 'class' => \common\components\DisableActionColumn::className(), 'template' => '{disable}<br>{statistic} {update} {delete} ', 'buttons' => ['statistic' => function ($url, $model, $key) {
    $options = ['class' => 'btn btn-default btn-xs', 'title' => Yii::t('app', 'User\'s statistic'), 'aria-label' => Yii::t('app', 'User\'s statistic')];
    return Html::a('<span class="glyphicon glyphicon-stats"></span>', \yii\helpers\Url::to(['/finances/person', 'id' => $model->ID]), $options);
}, 'delete' => function ($url, $model, $key) {