/** * Finds the Type model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Type the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if ($model = Type::get($id)) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php /** * @link http://zenothing.com/ */ use app\modules\pyramid\models\Type; use app\widgets\AjaxComplete; use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model app\modules\pyramid\models\Node */ /* @var $form yii\widgets\ActiveForm */ $types = Type::getItems(); ?> <div class="type-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'user_name')->widget(AjaxComplete::class, ['route' => ['/user/complete']]); ?> <?php echo $form->field($model, 'type_id')->dropDownList($types); ?> <?php if (!$model->isNewRecord) { echo $form->field($model, 'count'); }
public function __toString() { return $this->id . ' ' . Type::get($this->type_id); }
/** * @param $id * @return Type|null */ public static function get($id) { $types = Type::all(); return isset($types[$id]) ? $types[$id] : null; }
use app\modules\pyramid\models\Income; use app\modules\pyramid\models\Type; use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View * @var $searchModel \app\modules\pyramid\models\search\Income * @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('app', 'Income'); ?> <div class="archive-index middle"> <h1 class="bagatelle"><?php echo Html::encode($this->title); ?> </h1> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => "{pager}\n{errors}\n{summary}\n{items}", 'columns' => ['id', ['attribute' => 'node_id', 'label' => Yii::t('app', 'Investment'), 'format' => 'html', 'value' => function (Income $model) { return $model->node_id ? Html::a($model->node, ['node', 'id' => $model->node_id]) : $model->node_id; }], ['attribute' => 'user_name', 'format' => 'html', 'value' => function (Income $model) { return Html::a($model->user_name, ['/user/view', 'name' => $model->user_name]); }], ['attribute' => 'type_id', 'label' => Yii::t('app', 'Plan'), 'format' => 'html', 'value' => function (Income $model) { return Html::a($model->type, ['view', 'id' => $model->type_id < 4 ? $model->type_id : 4]); }], ['attribute' => 'type_id', 'label' => Yii::t('app', 'Income'), 'value' => function (Income $model) { return Type::get($model->type_id)->income; }], 'time:datetime']]); ?> </div>
/** * @link http://zenothing.com/ */ use app\modules\pyramid\models\Type; use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('app', 'Plans'); $description = 'Для удобства работы в нашем проекте, администрация проекта решила создать 4 тарифных плана для потенциальных клиентов нашего проекта. Маркетинг план состоит из 3 активных планов для заработка в нашем проекте'; $this->registerMetaTag(['name' => 'description', 'content' => $description]); $columns = ['name', 'stake', 'income', ['label' => 'reinvest', 'value' => function (Type $model) { if ($model->reinvest) { return Type::get($model->reinvest); } return null; }], ['label' => Yii::t('app', 'Action'), 'format' => 'html', 'value' => function (Type $model) { if ($model->visibility) { if (Yii::$app->user->isGuest) { return Html::a('Open', ['/user/signup', 'type_id' => $model->id], ['class' => 'btn btn-success btn-sm']); } else { /** @var \app\models\User $user */ $user = Yii::$app->user->identity; if (Yii::$app->user->identity->isManager()) { return Html::a('Create', ['/pyramid/node/create', 'type_id' => $model->id], ['class' => 'btn btn-success btn-sm']); } elseif ($user->account >= $model->stake) { return Html::a('Open', ['view', 'id' => $model->id], ['class' => 'btn btn-success btn-sm']); } else { return Yii::t('app', 'Insufficient funds');
public function actionEmail($code) { /** @var User $user */ if (!Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin()) { $user = User::findOne(['name' => $code]); } else { $user = preg_match('|^[\\w\\-_]{64}$|', $code) ? User::findOne(['code' => $code]) : null; } if ($user) { $bundle = $user->getBundle(); if (!$bundle) { Yii::$app->session->addFlash('error', Yii::t('app', 'The user can not be activated')); return $this->redirect(Yii::$app->user->isGuest ? ['home/index'] : ['user/view', 'name' => $user->name]); } $message = empty($user->hash) ? 'Congratulations. You have successfully activated!' : 'Your email changed!'; if (empty($user->hash) && empty($bundle['ref_name'])) { $bundle['ref_name'] = 'Kruzik'; } $attributes = $user->activeAttributes(); $attributes[] = 'hash'; $redirect = ['user/view']; foreach ($bundle as $name => $value) { if (in_array($name, $attributes)) { $user->{$name} = $value; } elseif (isset($bundle['type_id'])) { $type = Type::get($bundle['type_id']); $redirect = ['/invoice/invoice/create', 'amount' => $type->stake]; $_SESSION['type_id'] = $type->id; } } $user->code = null; $user->setBundle(null); if ($user->save()) { Yii::$app->session->addFlash('success', Yii::t('app', $message)); Yii::$app->user->login($user); return $this->redirect($redirect); } else { Yii::$app->session->addFlash('error', Yii::t('app', 'Something wrong happened')); } } else { Yii::$app->session->addFlash('error', Yii::t('app', 'Invalid code')); } return $this->redirect(['home/index']); }
/** * @return Type */ public function getType() { return Type::get($this->type_id); }
<div> <img src="/images/woman.png"> </div> <div> <div>Простой понятный и доступный маркетинг, без квалификаций, без подтверждений, нет ежемесячной абонентской платы, партнерская программа, одним словом есть ВСЕ необходимое.</div> </div> </div> </div> </section> <section class="plans center"> <div> <h2><strong>Планы</strong> и ценообразования</h2> <?php $names = []; $signups = []; foreach (Type::all() as $type) { if ($type->visibility) { $names[] = Html::tag('div', Html::tag('div', Html::tag('div', $type->name) . Html::tag('div', '$' . $type->stake), ['class' => 'inner'])); $signups[] = Html::tag('div', Html::tag('div', Html::a(Yii::t('app', 'Signup'), ['/user/signup', 'type_id' => $type->id], ['class' => 'button']), ['class' => 'inner'])); } } ?> <div class="block-table"> <div> <?php echo implode("\n", $names); ?> </div> <div> <?php echo implode("\n", $signups);