Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => array('pageSize' => 100), 'sort' => array('defaultOrder' => ['created_at' => SORT_DESC])]);
     $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, 'gender' => $this->gender, 'status' => $this->status, 'role_id' => $this->role_id]);
     $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'created_at', CFF::FormatData($this->created_at)])->andFilterWhere(['like', 'updated_at', CFF::FormatData($this->updated_at)])->andFilterWhere(['like', 'birthday', $this->birthday])->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_confirm_token', $this->email_confirm_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'photo', $this->photo]);
     return $dataProvider;
 }
Beispiel #2
0
    ?>
                                    <?php 
    echo Html::a('', ['/login/facebook'], ['
                                    class' => 'oauth-fb', 'title' => 'Войти с помощью аккаунта Facebook', 'rel' => 'external nofollow']);
    ?>
                                </div>
                                <?php 
} else {
    $identity = Yii::$app->getUser()->getIdentity();
    ?>
                                <div class="ava">
                                <?php 
    echo "<span class='hidden-xs'>" . Html::beginTag('a', ['href' => '/me', 'title' => 'Личный кабинет']);
    $options = ['alt' => 'Аватар', 'title' => 'Аватар', 'class' => 'avatar'];
    if (isset($identity->photo) && $identity->photo) {
        echo Html::img(CFF::getThumb($identity->photo), $options);
    } else {
        if (isset($identity->gender) && $identity->gender == 2) {
            echo Html::img('/css/image/f_pic.png', $options);
        } else {
            echo Html::img('/css/image/m_pic.png', $options);
        }
    }
    echo "</span>" . Html::endTag('a');
    echo '<i class="glyphicon glyphicon-user hidden-lg hidden-md hidden-sm"></i> ';
    if (isset($identity->first_name)) {
        echo Html::a($identity->first_name, ['/me'], ['class' => 'enter link', 'title' => 'Личный кабинет']);
    }
    echo ' <span class="hidden-xs"></br></span>' . Html::a('Выйти', ['/logout'], ['class' => 'enter link', 'title' => 'Выйти из аккаунта']);
    ?>
                                </div>
Beispiel #3
0
 public function beforeValidate()
 {
     if ($this->scenario != 'search') {
         $this->setAuthor();
         if ($this->isNewRecord) {
             $this->created_at = date('Y-m-d H:i:s');
             $this->created_ip = CFF::getIP();
         } else {
             $this->updated_at = date('Y-m-d H:i:s');
         }
         if (!$this->for_document_id && !$this->for_user_id) {
             $this->addError('for_document_id', 'Обязательна принадлежность
              сообщения или пользователю или документу');
             $this->addError('for_user_id', 'Обязательна принадлежность
              сообщения или пользователю или документу');
         }
     }
     return true;
 }
Beispiel #4
0
 /**
  * @return bool
  */
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         //Удаляем дополнительные поля документа
         Field::deleteAll('document_id = :document_id', [':document_id' => $this->id]);
         //Удаляем папку со связанными файлами документа
         CFF::RemoveDir(Document::FROM_ADM_PATH . Document::FILES_PATH . $this->id);
         return true;
     } else {
         return false;
     }
 }
Beispiel #5
0
        echo Html::img('/css/image/f_pic.png', $options);
    } else {
        echo Html::img('/css/image/m_pic.png', $options);
    }
}
?>
    </div>

    <div class="col-sm-2">
    <b>Пол:</b>
        <?php 
echo $model->gender ? $model->gender == 1 ? "Мужской" : "Женский" : "<span class='hint'>Не указан</span>";
?>
    <br><b>Дата рождения:</b>
        <?php 
echo $model->birthday ? CFF::formatData($model->birthday) : "<span class='hint'>Не указана</span>";
?>
    </div>

    <div class="col-sm-8">
        <div class="social">
            <?php 
if ($model->vk_page) {
    echo Html::a('', $model->vk_page, ['title' => 'Аккаунт Вконтакте', 'class' => 'vk-active', 'target' => '_blank']);
} else {
    echo Html::a('', $model->vk_page, ['title' => 'Аккаунт Вконтакте', 'class' => 'vk']);
}
if ($model->ok_page) {
    echo Html::a('', $model->ok_page, ['title' => 'Аккаунт Одноклассники', 'class' => 'ok-active', 'target' => '_blank']);
} else {
    echo Html::a('', $model->ok_page, ['title' => 'Аккаунт Одноклассники', 'class' => 'ok']);
Beispiel #6
0
 /**
  * @return bool
  */
 public function deletePhoto()
 {
     if ($this->value) {
         if (file_exists(Document::FROM_ADM_PATH . $this->value)) {
             unlink(Document::FROM_ADM_PATH . $this->value);
         }
         $thumb = CFF::getThumb($this->value);
         if (file_exists(Document::FROM_ADM_PATH . $thumb)) {
             unlink(Document::FROM_ADM_PATH . $thumb);
         }
         $this->value = null;
     }
     return true;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = Document::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $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, 'lft' => $this->lft, 'rgt' => $this->rgt, 'depth' => $this->depth, 'template_id' => $this->template_id, 'is_folder' => $this->is_folder, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'created_user_name', $this->created_user_name])->andFilterWhere(['like', 'updated_user_name', $this->updated_user_name])->andFilterWhere(['like', 'root_name', $this->root_name])->andFilterWhere(['like', 'parent_name', $this->parent_name])->andFilterWhere(['like', 'created_at', CFF::FormatData($this->created_at)])->andFilterWhere(['like', 'updated_at', CFF::FormatData($this->updated_at)])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'annotation', $this->annotation])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['>=', 'id', $this->id_from])->andFilterWhere(['<=', 'id', $this->id_till])->andFilterWhere(['<>', 'id', 1]);
     for ($i = 1; $i <= Template::OPTIONS_COUNT; $i++) {
         $option = 'option_' . $i;
         $query->andFilterWhere(['like', $option, $this->{$option}]);
     }
     if ($this->created_at_from) {
         $query->andFilterWhere(['>=', 'created_at', CFF::FormatData($this->created_at_from, false) . ' 00:00:00']);
     }
     if ($this->created_at_till) {
         $query->andFilterWhere(['<=', 'created_at', CFF::FormatData($this->created_at_till, false) . ' 23:59:00']);
     }
     if ($this->updated_at_from) {
         $query->andFilterWhere(['>=', 'updated_at', CFF::FormatData($this->updated_at_from, false) . ' 00:00:00']);
     }
     if ($this->updated_at_till) {
         $query->andFilterWhere(['<=', 'updated_at', CFF::FormatData($this->updated_at_till, false) . ' 23:59:00']);
     }
     return $dataProvider;
 }
Beispiel #8
0
    <?php 
echo $this->render('@app/views/site/_alert');
?>

<?php 
$gridColumns = [['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '30px', 'header' => '', 'headerOptions' => ['class' => 'kartik-sheet-style']], ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '50px', 'value' => function () {
    return GridView::ROW_COLLAPSED;
}, 'detail' => function ($model) {
    return Yii::$app->controller->renderPartial('_view', ['model' => $model]);
}, 'headerOptions' => ['class' => 'kartik-sheet-style']], ['attribute' => 'id', 'width' => '70px'], ['attribute' => 'role_id', 'value' => function ($model) {
    return isset($model->role) ? $model->role->name : '';
}, 'filter' => AuthItem::getAll(1), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '', 'class' => 'form-control'], 'format' => 'raw'], ['attribute' => 'first_name', 'format' => 'html', 'value' => function ($model) {
    return Html::a($model->first_name, ['/user/update', 'id' => $model->id]);
}], 'last_name', 'email:email', 'phone', ['attribute' => 'created_at', 'value' => function ($model) {
    return CFF::FormatData($model->created_at, true);
}, 'width' => '200px', 'filter' => DatePicker::widget(['value' => isset($_GET['UserSearch']['created_at']) ? $_GET['UserSearch']['created_at'] : '', 'name' => 'UserSearch[created_at]', 'type' => DatePicker::TYPE_COMPONENT_APPEND, 'pluginOptions' => ['format' => 'dd.mm.yyyy', 'todayHighlight' => true]])], ['attribute' => 'status', 'vAlign' => 'middle', 'format' => 'raw', 'value' => function ($model) {
    switch ($model->status) {
        case User::STATUS_BLOCKED:
            return '<span class="label label-danger">
                        <i class="glyphicon glyphicon-lock"></i> Заблокирован</span>';
            break;
        case User::STATUS_WAIT:
            return '<span class="label label-warning">
                        <i class="glyphicon glyphicon-hourglass"></i> Не активен</span>';
            break;
        case User::STATUS_ACTIVE:
            return '<span class="label label-success">
                        <i class="glyphicon glyphicon-ok"></i> Активен</span>';
            break;
    }
Beispiel #9
0
 /**
  * @return bool
  * @throws \yii\db\Exception
  * Удаление аватара
  */
 public function deletePhoto()
 {
     if ($this->photo) {
         if (file_exists($this->photo)) {
             unlink($this->photo);
         }
         $thumb = CFF::getThumb($this->photo);
         if (file_exists($thumb)) {
             unlink($thumb);
         }
         if (!$this->isNewRecord) {
             $db = User::getDb();
             $db->createCommand()->update('user', ['photo' => null], ['id' => $this->id])->execute();
         }
     }
     return true;
 }
Beispiel #10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = Message::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $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, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_user_id' => $this->created_user_id, 'updated_user_id' => $this->updated_user_id, 'for_document_id' => $this->for_document_id, 'for_user_id' => $this->for_user_id, 'parent_message_id' => $this->parent_message_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'attachment', $this->attachment])->andFilterWhere(['like', 'created_user_name', $this->created_user_name])->andFilterWhere(['like', 'updated_user_name', $this->updated_user_name])->andFilterWhere(['like', 'created_ip', $this->created_ip])->andFilterWhere(['>=', 'id', $this->id_from])->andFilterWhere(['<=', 'id', $this->id_till]);
     for ($i = 1; $i <= Message::OPTIONS_COUNT; $i++) {
         $option = 'option_' . $i;
         $query->andFilterWhere(['like', $option, $this->{$option}]);
     }
     if ($this->created_at_from) {
         $query->andFilterWhere(['>=', 'created_at', CFF::FormatData($this->created_at_from, false) . ' 00:00:00']);
     }
     if ($this->created_at_till) {
         $query->andFilterWhere(['<=', 'created_at', CFF::FormatData($this->created_at_till, false) . ' 23:59:00']);
     }
     if ($this->updated_at_from) {
         $query->andFilterWhere(['>=', 'updated_at', CFF::FormatData($this->updated_at_from, false) . ' 00:00:00']);
     }
     if ($this->updated_at_till) {
         $query->andFilterWhere(['<=', 'updated_at', CFF::FormatData($this->updated_at_till, false) . ' 23:59:00']);
     }
     return $dataProvider;
 }
Beispiel #11
0
use yii\helpers\Html;
use common\helpers\CFF;
use kartik\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\FieldSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Поиск по полям';
?>
<div class="field-index">

<?php 
$gridColumns = [['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '30px', 'header' => '', 'headerOptions' => ['class' => 'kartik-sheet-style']], ['attribute' => 'id', 'width' => '70px'], ['attribute' => 'option_id', 'format' => 'raw', 'value' => function ($model) {
    $return = isset($model->option) ? Html::a($model->option->name, ['/document/update', 'id' => $model->document_id, '#' => 'field-' . $model->id]) : "";
    $return .= " (" . $model->option_id . ")";
    return $return;
}], ['attribute' => 'document_id', 'format' => 'raw', 'value' => function ($model) {
    $return = isset($model->document) ? Html::a($model->document->name, ['/document/update', 'id' => $model->document_id]) : "";
    $return .= " (" . $model->document_id . ")";
    return $return;
}], 'position', ['attribute' => 'value', 'format' => 'raw', 'value' => function ($model) {
    return CFF::shortString($model->value, 200);
}], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update}', 'buttons' => ['update' => function ($url, $model, $key) {
    $options = ['title' => Yii::t('yii', 'Update'), 'aria-label' => Yii::t('yii', 'Update'), 'data-pjax' => '0'];
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['/document/update', 'id' => $model->document_id, '#' => 'field-' . $key], $options);
}]]];
echo GridView::widget(['layout' => "{items}\n{summary}\n{pager}", 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'containerOptions' => ['style' => 'overflow: auto'], 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'filterRowOptions' => ['class' => 'kartik-sheet-style'], 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> Поиск по полям</h3>', 'type' => GridView::TYPE_PRIMARY], 'export' => ['fontAwesome' => true], 'bordered' => true, 'striped' => true, 'condensed' => true, 'persistResize' => false, 'hover' => true, 'responsive' => true]);
?>

</div>