Commit ab1aa91f authored by Shakarim Sapa's avatar Shakarim Sapa

Merge remote-tracking branch 'origin/master'

parents d3046595 76db3778
......@@ -23,7 +23,7 @@ class HeadAsset extends AssetBundle
'plugins/switchery/switchery.min.js',
'plugins/powerange/powerange.min.js',
'plugins/pace/pace.min.js',
'js/form-slider-switcher.demo.min.js',
'js/form-slider-switcher.demo.js',
'js/packages/adminBaseClasses/buttonSet.js',
'js/packages/adminBaseClasses/gridBase.js',
'js/apps.min.js',
......
......@@ -9,6 +9,62 @@
border-color: #79C137;
}
.btn.btn-success.active, .btn.btn-success:active, .btn.btn-success:focus, .btn.btn-success:hover, .open .dropdown-toggle.btn-success {
background: #487421;
border-color: #487421;
}
.color-column {
white-space: nowrap;
}
.btn.btn-inverse-grey {
background: #6d7479;
border-color: #6d7479;
color: white;
}
.btn.btn-inverse-grey.active, .btn.btn-inverse-grey:active, .btn.btn-inverse-grey:focus, .btn.btn-inverse-grey:hover, .open .dropdown-toggle.btn-inverse-grey {
background: #2d353c;
border-color: #2d353c;
}
.progress-bar.progress-bar-success {
background-color: #79c137;
}
.dataTables_filter {
float: left;
width: 75%;
}
.dataTables_filter label {
width: 100%;
}
.dataTables_filter input {
margin-left: 0;
width: 100% !important;
}
.dt-buttons.btn-group {
float: right;
}
.dataTables_info {
padding-bottom: 8px;
}
.has-success .form-control {
border-color: #79C137;
}
.has-success .checkbox, .has-success .checkbox-inline, .has-success .control-label, .has-success .form-control-feedback, .has-success .help-block, .has-success .radio, .has-success .radio-inline {
color: #79C137;
}
.alert.alert-success {
background-color: #e1ecd8;
color: #365e11;
}
.progress-bar.progress-bar-success {
background-color: #79c137;
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ var green = '#00acac',
purple = '#727cb6',
orange = '#f59c1a',
black = '#2d353c';
success = '#79C137';
var renderSwitcher = function() {
if ($('[data-render=switchery]').length !== 0) {
......@@ -33,6 +34,9 @@ var renderSwitcher = function() {
case 'black':
themeColor = black;
break;
case 'success':
themeColor = success;
break;
}
}
var option = {};
......
......@@ -84,7 +84,7 @@ class BaseForm extends \yii\widgets\ActiveForm
switch($element['type']) {
case 'checkbox':
$opt['data-render'] = 'switchery';
$opt['data-theme'] = 'default';
$opt['data-theme'] = 'success';
$opt['data-classname'] = 'switchery';
if(!empty($element['opts']))
$opt = array_merge($opt, $element['opts']);
......@@ -133,7 +133,7 @@ class BaseForm extends \yii\widgets\ActiveForm
break;
case 'checkboxList':
$opt['data-render'] = 'switchery';
$opt['data-theme'] = 'default';
$opt['data-theme'] = 'success';
$opt['data-classname'] = 'switchery';
$config['options'][] = $this->field($this->model, $key, $optEl)->checkboxList(
$element['items'],
......
......@@ -4,7 +4,6 @@ namespace common\components\zii;
use common\components\zii\AdminLinkPager;
class AdminGrid extends GridView
{
public $sortable = false;
public $pager = array('class'=> '\common\components\zii\AdminLinkPager');
public $cssFile = "/css/admin/gridview/styles.css";
......
......@@ -155,7 +155,7 @@ class GridView extends \himiklab\sortablegrid\SortableGridView
$return .= "<table class='".$this->tableOptions['class']."' cellpadding='0' cellspacing='0' width='100%'>\n";
$return .= $this->renderTableHeader();
$return .= $this->renderTableBody();
$return .= $this->renderTableFooter();
// $return .= $this->renderTableFooter();
$return .= "</table>";
if ($this->mass_removal)
......
......@@ -61,6 +61,9 @@ class LoginForm extends Model
{
$user = $this->getUser();
$user->last_logon = time();
$user->save(false, ['last_logon']);
return Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0);
}
......
......@@ -147,15 +147,27 @@ class RoleAdminController extends \common\components\AdminController
];
$modules = [];
$columns = [];
$columns[] = [
'label' => 'ФИО',
'format' => 'raw',
/*'contentOptions' => ['style'=>'width: 100px;'],*/
'value' => function($model) {
return \yii\helpers\Html::a($model->getCustomName(),\yii\helpers\Url::toRoute(['/users/user-admin/update', 'id'=>$model->id]));
}
$columns = [
[
'label' => 'ФИО',
'attribute' => 'fullName',
'format' => 'raw',
'value' => function($model) {
return \yii\helpers\Html::a($model->getCustomName(),\yii\helpers\Url::toRoute(['/users/user-admin/update', 'id'=>$model->id]));
}
],
[
'label' => 'Дата добавления пользователя',
'attribute' => 'date_create',
],
[
'label' => 'Последний вход в систему',
'attribute' => 'last_logon',
'filter' => false,
'value' => function($model) {
return ($model->last_logon?date('d.m.Y H:i', $model->last_logon):null);
}
]
];
foreach(\common\components\AppManager::getModulesList() as $module_id => $module_name) {
......@@ -187,7 +199,7 @@ class RoleAdminController extends \common\components\AdminController
$val = \yii::$app->authManager->checkAccess($model->id, $module_id);
return \yii\helpers\Html::checkBox($module_id.'_'.$model->id, $val, [
'data-render'=>'switchery',
'data-theme'=>'default',
'data-theme'=>'success',
'data-classname'=>'switchery',
'user-id' => $model->id,
'item' => $module_id,
......
......@@ -12,7 +12,7 @@ use common\components\zii\AdminGrid;
];
?>
<p>
<?= Html::a(Yii::t('units', 'Создать пользователя', [
<?= Html::a(Yii::t('units', 'Создать нового пользователя', [
'modelClass' => 'Modules',
]), ['/users/user-admin/create'], ['class' => 'btn btn-success']) ?>
</p>
......@@ -29,6 +29,7 @@ $not_system_role = '!in_array($data->name, AuthItem::$system_roles)';
echo AdminGrid::widget([
'id' => 'access-grid-roles',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'rowOptions' => function ($model, $index, $widget, $grid){
if($model->status == 'blocked')
//return ['style'=>'background-color:#575d63 !important;'];
......
......@@ -44,6 +44,7 @@ return [
'data-change' => 'check-switchery-state-text'
]
],
'<div class="col-md-4 col-sm-6" style="float:right;margin-top:-47px;"><div class="widget widget-stats bg-blue"><span><i class="icon-question"></i>&nbsp;&nbsp;&nbsp;<b>Заблокирован</b><br>Если пользователь заблокирован, то он не сможет войти в систему.<br>Данные внесенные пользователем не удаляются. </span></div></div>',
'role' => [
'type' => 'dropdownlist',
'items' => User::$role_list,
......@@ -59,15 +60,12 @@ return [
'buttons' => [
'sp1' => ['type' => 'htmlBlock', 'value' => '<div class="col-md-8 col-sm-6" style="padding-left: 0;">',],
'submit' => ['type' => 'submit', 'value' => 'Cохранить'],
'sp11' => ['type' => 'htmlBlock', 'value' => '&nbsp;&nbsp;&nbsp;&nbsp;',],
'block' => ['type' => 'info', 'value' => 'Заблокировать'],
'sp12' => ['type' => 'htmlBlock', 'value' => '&nbsp;&nbsp;&nbsp;&nbsp;',],
'delete' => ['type' => 'danger', 'value' => 'Удалить'],
'sp2' => ['type' => 'htmlBlock', 'value' => '</div>',],
'sp3' => ['type' => 'htmlBlock', 'value' => '<div class="col-md-4 col-sm-6" style="padding-right: 0;">',],
'sp4' => ['type' => 'htmlBlock', 'value' => '<div class="widget widget-stats bg-blue">',],
'sp5' => ['type' => 'htmlBlock', 'value' => '<span class=""><i class="icon-question"></i>&nbsp;&nbsp;&nbsp;<b>Заблокирован</b><br>Если пользователь заблокирован, то он не сможет войти в систему.<br>Данные внесенные пользователем не удаляются. </span><br><br>',],
'sp6' => ['type' => 'htmlBlock', 'value' => '<span class=""><i class="icon-question"></i>&nbsp;&nbsp;&nbsp;<b>Удален</b><br>Внимание! Все данные пользователя введенные<br>под его именем будут безвозвратно удалены</span><br>',],
'sp7' => ['type' => 'htmlBlock', 'value' => '</div>',],
'sp8' => ['type' => 'htmlBlock', 'value' => '</div>',],
......
<?php
use yii\db\Migration;
class m160505_121558_add_column extends Migration
{
public function up()
{
$this->addColumn('users', 'last_logon', $this->integer(11));
}
public function down()
{
$this->dropColumn('users', 'last_logon', $this->integer(11));
}
}
<?php
/**
* LoginForm class.
* LoginForm is the data structure for keeping
* user login form data. It is used by the 'login' action of 'SiteController'.
*/
class LoginForm extends CFormModel
{
public $email;
public $password;
public $rememberMe;
private $_identity;
/**
* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
*/
public function rules()
{
return array(
// username and password are required
array('email, password', 'required'),
// rememberMe needs to be a boolean
array('rememberMe', 'boolean'),
// password needs to be authenticated
array('password', 'authenticate'),
);
}
public static function model($className = __CLASS__)
{
return parent::model($className);
}
/**
* Declares attribute labels.
*/
public function attributeLabels()
{
return array(
'email' => 'Логин',
'rememberMe'=>'Remember me next time',
);
}
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute,$params)
{
if(!$this->hasErrors())
{
$this->_identity=new UserIdentity($this->email,$this->password);
if(!$this->_identity->authenticate())
$this->addError('password','Incorrect username or password.');
}
}
/**
* Logs in the user using the given username and password in the model.
* @return boolean whether login is successful
*/
public function login()
{
if($this->_identity===null)
{
$this->_identity=new UserIdentity($this->email,$this->password);
$this->_identity->authenticate();
}
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->login($this->_identity,$duration);
return true;
}
else
return false;
}
}
......@@ -96,6 +96,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public $tmp; //for external using. no delete!
public $profile;
public $fullName;
public static $role_list = [
self::ROLE_ADMIN => 'Доступ в админ-панель',
......@@ -160,7 +161,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self::SCENARIO_SEND_NEW_PASSWORD,
self::SCENARIO_RECOVER_PASSWORD
], 'message' => 'Пожалуйста, укажите корректный e-mail адрес'],
[['send_email', 'redmine_key'], 'safe'],
[['send_email', 'redmine_key', 'fullName', 'last_logon'], 'safe'],
[['fio','name', 'surname'], 'safe', 'on' => [
self::SCENARIO_CREATE,
], 'message' => 'Пожалуйста, укажите Ваше имя'],
......@@ -374,13 +375,11 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
return parent::model($className);
}
public static function tableName()
{
return 'users';
}
public function name()
{
return "Пользователи";
......@@ -404,6 +403,16 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
return $score;
}
public function getFullName()
{
return $this->name . ' ' . $this->surname;
}
public function setFullName($value)
{
$this->fullName = $value;
}
public function getCustomName($user = null)
{
if (!$user)
......
......@@ -19,8 +19,8 @@ class UserSearch extends User
public function rules()
{
return [
[['id', 'is_deleted', 'sort'], 'integer'],
[['fio', 'status', 'email'], 'safe'],
[['id', 'is_deleted', 'sort', 'last_logon'], 'integer'],
[['fio', 'status', 'email', 'fullName'], 'safe'],
];
}
......@@ -44,27 +44,27 @@ class UserSearch extends User
{
$query = User::find();
$sort = new Sort([
'attributes' => [
'status' => [
'asc' => ['status' => SORT_ASC],
'desc' => ['status' => SORT_DESC],
'default' => SORT_DESC,
'label' => 'Статус',
],
],
]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort'=> ['defaultOrder' => ['status'=>SORT_ASC]]
//'sort' => $sort
'sort' => [
'defaultOrder' => ['status'=>SORT_ASC],
'attributes' => [
'status' => [
'asc' => ['status' => SORT_ASC],
'desc' => ['status' => SORT_DESC],
'default' => SORT_DESC,
'label' => 'Статус',
],
'fullName' => [
'asc' => ['fullName' => SORT_ASC],
'desc' => ['fullName' => SORT_DESC],
],
'date_create',
'last_logon'
],
]
]);
/*$dataProvider->setSort([
'defaultOrder' => ['status'=>SORT_DESC],]);*/
$this->load($params);
if (!$this->validate()) {
......@@ -73,26 +73,21 @@ class UserSearch extends User
return $dataProvider;
}
$query->select(['*', "CONCAT(name, ' ', surname) as fullName"]);
if($this->fullName)
{
$query->andHaving([
'fullName' => $this->fullName,
]);
}
$query->andFilterWhere([
'id' => $this->id,
'is_deleted' => $this->is_deleted,
'sort' => $this->sort,
]);
$query->andFilterWhere([
'email', 'name', $this->email,
'fio', 'name', $this->fio,
'status', 'name', $this->status,
]);
if(!empty($_REQUEST['Search']['phrase']))
$query->andFilterWhere([
'like', 'first_name', $this->first_name,
'like', 'last_name', $this->last_name,
'like', 'patronymic', $this->patronymic,
'like', 'email', $this->email,
]);
return $dataProvider;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment