Пример #1
0
 /**
  * @param string $attribute
  * @param array $params
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         if (!$this->_user->validatePassword($this->{$attribute})) {
             $this->addError($attribute, Yii::t('app', 'ERROR_WRONG_CURRENT_PASSWORD'));
         }
     }
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Пример #3
0
$content = Html::tag('h3', '<i class="glyphicon glyphicon-calendar"></i>Пользователи', ['class' => "panel-title"]);
echo Html::tag('div', $content, ['class' => "panel-heading"]);
echo Html::endTag('div');
?>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Добавить пользователя', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'headerOptions' => ['class' => 'col-md-1']], ['attribute' => 'username', 'format' => 'raw', 'value' => function ($model) {
    return Html::a($model->username, '/admin/user/view?id=' . $model->id, ['target' => '_blank']);
}], 'name', ['attribute' => 'status', 'format' => 'raw', 'value' => function ($model) {
    if ($model->status == 10) {
        $class = 'label-success';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . User::getStatusName($model->status) . '</span>';
}], ['label' => 'Роли', 'value' => function ($model) {
    return implode(',', $model->roles);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'user_id']);
 }
Пример #5
0
 /**
  * Получение ФИО пользователя
  * @param integer $id
  * @return mixed
  */
 public function actionGetName($id)
 {
     $model = User::findOne($id);
     if ($model !== null) {
         $result = $model->name;
     } else {
         $result = false;
     }
     return $result;
 }
Пример #6
0
$this->title = 'Приём к врачу';
$this->params['breadcrumbs'][] = ['label' => 'График', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="records-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
if (!Yii::$app->user->isGuest && $model->reserved) {
    echo Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
    echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Удалить запись?', 'method' => 'post']]);
    //            if (!$model->visited)
    //            {
    $id = $model->id;
    echo Html::a('Посещение', ['records/add-visit', 'id' => $id], ['class' => 'btn btn-success']);
    //            }
}
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'specialist.doctor.name', 'label' => 'Врач', 'format' => 'raw', 'value' => Html::a($model->specialist->doctor->name, ['/specialists/view', 'id' => $model->specialist_id], ['title' => $model->specialist->doctor->description])], ['attribute' => 'specialist.occupation.name', 'label' => 'Специальность'], ['attribute' => 'start_time'], ['attribute' => 'name'], ['attribute' => 'phone'], ['attribute' => 'email'], ['attribute' => 'reserved', 'format' => 'raw', 'value' => $model->reserved ? '<span class="label label-success">Да</span>' : '<span class="label label-danger">Нет</span>'], ['attribute' => 'visited', 'format' => 'raw', 'value' => $model->visited ? '<span class="label label-success">Да</span>' : '<span class="label label-danger">Нет</span>'], ['attribute' => 'user_id', 'format' => 'html', 'value' => $model->user_id ? User::findOne($model->user_id)->name : 'Интернет-пользователь'], ['attribute' => 'visit_type', 'label' => 'Тип посещения', 'visible' => !is_null($model->visit_type), 'value' => $model->visit_type ? 'Договор страхования' : 'Наличные'], ['attribute' => 'insurer_id', 'label' => 'Страховщик', 'visible' => is_numeric($model->insurer_id), 'value' => $model->insurer_id ? $model->insurer->name : 'Не задано'], 'created_at', 'updated_at']]);
?>

</div>
Пример #7
0
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Вы уверены что хотите удалить этого пользователя?', 'method' => 'post']]);
?>
        <?php 
echo Html::a('Изменить пароль', ['password-change', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
$status = User::getStatusName($model->status);
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'username', 'name', 'email:email', ['attribute' => 'status', 'format' => 'raw', 'value' => $model->status == 10 ? '<span class="label label-success">' . $status . '</span>' : '<span class="label label-danger">' . $status . '</span>'], ['attribute' => 'created_at', 'value' => date('d-M-Y H:i:s', $model->created_at)], ['attribute' => 'updated_at', 'value' => date('d-M-Y H:i:s', $model->updated_at)]]]);
echo Html::tag('p', 'Назначенные роли');
$auth = AuthAssignment::findAll(['user_id' => $model->id]);
$assignment = [];
foreach ($auth as $item) {
    $assignment[] = $item->item_name;
}
echo Html::listBox('roles', null, $assignment);
?>

</div>