merge cms

parent 0852bdae
...@@ -23,7 +23,7 @@ class HeadAsset extends AssetBundle ...@@ -23,7 +23,7 @@ class HeadAsset extends AssetBundle
'plugins/switchery/switchery.min.js', 'plugins/switchery/switchery.min.js',
'plugins/powerange/powerange.min.js', 'plugins/powerange/powerange.min.js',
'plugins/pace/pace.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/buttonSet.js',
'js/packages/adminBaseClasses/gridBase.js', 'js/packages/adminBaseClasses/gridBase.js',
'js/apps.min.js', 'js/apps.min.js',
......
...@@ -9,6 +9,62 @@ ...@@ -9,6 +9,62 @@
border-color: #79C137; 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 { .color-column {
white-space: nowrap; 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', ...@@ -11,6 +11,7 @@ var green = '#00acac',
purple = '#727cb6', purple = '#727cb6',
orange = '#f59c1a', orange = '#f59c1a',
black = '#2d353c'; black = '#2d353c';
success = '#79C137';
var renderSwitcher = function() { var renderSwitcher = function() {
if ($('[data-render=switchery]').length !== 0) { if ($('[data-render=switchery]').length !== 0) {
...@@ -33,6 +34,9 @@ var renderSwitcher = function() { ...@@ -33,6 +34,9 @@ var renderSwitcher = function() {
case 'black': case 'black':
themeColor = black; themeColor = black;
break; break;
case 'success':
themeColor = success;
break;
} }
} }
var option = {}; var option = {};
......
...@@ -84,7 +84,7 @@ class BaseForm extends \yii\widgets\ActiveForm ...@@ -84,7 +84,7 @@ class BaseForm extends \yii\widgets\ActiveForm
switch($element['type']) { switch($element['type']) {
case 'checkbox': case 'checkbox':
$opt['data-render'] = 'switchery'; $opt['data-render'] = 'switchery';
$opt['data-theme'] = 'default'; $opt['data-theme'] = 'success';
$opt['data-classname'] = 'switchery'; $opt['data-classname'] = 'switchery';
if(!empty($element['opts'])) if(!empty($element['opts']))
$opt = array_merge($opt, $element['opts']); $opt = array_merge($opt, $element['opts']);
...@@ -133,7 +133,7 @@ class BaseForm extends \yii\widgets\ActiveForm ...@@ -133,7 +133,7 @@ class BaseForm extends \yii\widgets\ActiveForm
break; break;
case 'checkboxList': case 'checkboxList':
$opt['data-render'] = 'switchery'; $opt['data-render'] = 'switchery';
$opt['data-theme'] = 'default'; $opt['data-theme'] = 'success';
$opt['data-classname'] = 'switchery'; $opt['data-classname'] = 'switchery';
$config['options'][] = $this->field($this->model, $key, $optEl)->checkboxList( $config['options'][] = $this->field($this->model, $key, $optEl)->checkboxList(
$element['items'], $element['items'],
......
...@@ -4,7 +4,6 @@ namespace common\components\zii; ...@@ -4,7 +4,6 @@ namespace common\components\zii;
use common\components\zii\AdminLinkPager; use common\components\zii\AdminLinkPager;
class AdminGrid extends GridView class AdminGrid extends GridView
{ {
public $sortable = false; public $sortable = false;
public $pager = array('class'=> '\common\components\zii\AdminLinkPager'); public $pager = array('class'=> '\common\components\zii\AdminLinkPager');
public $cssFile = "/css/admin/gridview/styles.css"; public $cssFile = "/css/admin/gridview/styles.css";
......
...@@ -155,7 +155,7 @@ class GridView extends \himiklab\sortablegrid\SortableGridView ...@@ -155,7 +155,7 @@ class GridView extends \himiklab\sortablegrid\SortableGridView
$return .= "<table class='".$this->tableOptions['class']."' cellpadding='0' cellspacing='0' width='100%'>\n"; $return .= "<table class='".$this->tableOptions['class']."' cellpadding='0' cellspacing='0' width='100%'>\n";
$return .= $this->renderTableHeader(); $return .= $this->renderTableHeader();
$return .= $this->renderTableBody(); $return .= $this->renderTableBody();
$return .= $this->renderTableFooter(); // $return .= $this->renderTableFooter();
$return .= "</table>"; $return .= "</table>";
if ($this->mass_removal) if ($this->mass_removal)
......
...@@ -61,6 +61,9 @@ class LoginForm extends Model ...@@ -61,6 +61,9 @@ class LoginForm extends Model
{ {
$user = $this->getUser(); $user = $this->getUser();
$user->last_logon = time();
$user->save(false, ['last_logon']);
return Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0); return Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0);
} }
......
...@@ -147,15 +147,27 @@ class RoleAdminController extends \common\components\AdminController ...@@ -147,15 +147,27 @@ class RoleAdminController extends \common\components\AdminController
]; ];
$modules = []; $modules = [];
$columns = []; $columns = [
[
$columns[] = [ 'label' => 'ФИО',
'label' => 'ФИО', 'attribute' => 'fullName',
'format' => 'raw', 'format' => 'raw',
/*'contentOptions' => ['style'=>'width: 100px;'],*/ 'value' => function($model) {
'value' => function($model) { return \yii\helpers\Html::a($model->getCustomName(),\yii\helpers\Url::toRoute(['/users/user-admin/update', 'id'=>$model->id]));
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 ($date->last_logon?date('d.m.Y H:i', $date->last_logon):null);
}
]
]; ];
foreach(\common\components\AppManager::getModulesList() as $module_id => $module_name) { foreach(\common\components\AppManager::getModulesList() as $module_id => $module_name) {
...@@ -187,7 +199,7 @@ class RoleAdminController extends \common\components\AdminController ...@@ -187,7 +199,7 @@ class RoleAdminController extends \common\components\AdminController
$val = \yii::$app->authManager->checkAccess($model->id, $module_id); $val = \yii::$app->authManager->checkAccess($model->id, $module_id);
return \yii\helpers\Html::checkBox($module_id.'_'.$model->id, $val, [ return \yii\helpers\Html::checkBox($module_id.'_'.$model->id, $val, [
'data-render'=>'switchery', 'data-render'=>'switchery',
'data-theme'=>'default', 'data-theme'=>'success',
'data-classname'=>'switchery', 'data-classname'=>'switchery',
'user-id' => $model->id, 'user-id' => $model->id,
'item' => $module_id, 'item' => $module_id,
......
...@@ -12,7 +12,7 @@ use common\components\zii\AdminGrid; ...@@ -12,7 +12,7 @@ use common\components\zii\AdminGrid;
]; ];
?> ?>
<p> <p>
<?= Html::a(Yii::t('units', 'Создать пользователя', [ <?= Html::a(Yii::t('units', 'Создать нового пользователя', [
'modelClass' => 'Modules', 'modelClass' => 'Modules',
]), ['/users/user-admin/create'], ['class' => 'btn btn-success']) ?> ]), ['/users/user-admin/create'], ['class' => 'btn btn-success']) ?>
</p> </p>
...@@ -29,6 +29,7 @@ $not_system_role = '!in_array($data->name, AuthItem::$system_roles)'; ...@@ -29,6 +29,7 @@ $not_system_role = '!in_array($data->name, AuthItem::$system_roles)';
echo AdminGrid::widget([ echo AdminGrid::widget([
'id' => 'access-grid-roles', 'id' => 'access-grid-roles',
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'rowOptions' => function ($model, $index, $widget, $grid){ 'rowOptions' => function ($model, $index, $widget, $grid){
if($model->status == 'blocked') if($model->status == 'blocked')
//return ['style'=>'background-color:#575d63 !important;']; //return ['style'=>'background-color:#575d63 !important;'];
......
...@@ -44,6 +44,7 @@ return [ ...@@ -44,6 +44,7 @@ return [
'data-change' => 'check-switchery-state-text' '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' => [ 'role' => [
'type' => 'dropdownlist', 'type' => 'dropdownlist',
'items' => User::$role_list, 'items' => User::$role_list,
...@@ -59,15 +60,12 @@ return [ ...@@ -59,15 +60,12 @@ return [
'buttons' => [ 'buttons' => [
'sp1' => ['type' => 'htmlBlock', 'value' => '<div class="col-md-8 col-sm-6" style="padding-left: 0;">',], 'sp1' => ['type' => 'htmlBlock', 'value' => '<div class="col-md-8 col-sm-6" style="padding-left: 0;">',],
'submit' => ['type' => 'submit', 'value' => 'Cохранить'], '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;',], 'sp12' => ['type' => 'htmlBlock', 'value' => '&nbsp;&nbsp;&nbsp;&nbsp;',],
'delete' => ['type' => 'danger', 'value' => 'Удалить'], 'delete' => ['type' => 'danger', 'value' => 'Удалить'],
'sp2' => ['type' => 'htmlBlock', 'value' => '</div>',], 'sp2' => ['type' => 'htmlBlock', 'value' => '</div>',],
'sp3' => ['type' => 'htmlBlock', 'value' => '<div class="col-md-4 col-sm-6" style="padding-right: 0;">',], '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">',], '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>',], '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>',], 'sp7' => ['type' => 'htmlBlock', 'value' => '</div>',],
'sp8' => ['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 ...@@ -96,6 +96,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public $tmp; //for external using. no delete! public $tmp; //for external using. no delete!
public $profile; public $profile;
public $fullName;
public static $role_list = [ public static $role_list = [
self::ROLE_ADMIN => 'Доступ в админ-панель', self::ROLE_ADMIN => 'Доступ в админ-панель',
...@@ -160,7 +161,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -160,7 +161,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self::SCENARIO_SEND_NEW_PASSWORD, self::SCENARIO_SEND_NEW_PASSWORD,
self::SCENARIO_RECOVER_PASSWORD self::SCENARIO_RECOVER_PASSWORD
], 'message' => 'Пожалуйста, укажите корректный e-mail адрес'], ], 'message' => 'Пожалуйста, укажите корректный e-mail адрес'],
[['send_email', 'redmine_key'], 'safe'], [['send_email', 'redmine_key', 'fullName', 'last_logon'], 'safe'],
[['fio','name', 'surname'], 'safe', 'on' => [ [['fio','name', 'surname'], 'safe', 'on' => [
self::SCENARIO_CREATE, self::SCENARIO_CREATE,
], 'message' => 'Пожалуйста, укажите Ваше имя'], ], 'message' => 'Пожалуйста, укажите Ваше имя'],
...@@ -374,13 +375,11 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -374,13 +375,11 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
return parent::model($className); return parent::model($className);
} }
public static function tableName() public static function tableName()
{ {
return 'users'; return 'users';
} }
public function name() public function name()
{ {
return "Пользователи"; return "Пользователи";
...@@ -404,6 +403,16 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -404,6 +403,16 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
return $score; return $score;
} }
public function getFullName()
{
return $this->name . ' ' . $this->surname;
}
public function setFullName($value)
{
$this->fullName = $value;
}
public function getCustomName($user = null) public function getCustomName($user = null)
{ {
if (!$user) if (!$user)
......
...@@ -19,8 +19,8 @@ class UserSearch extends User ...@@ -19,8 +19,8 @@ class UserSearch extends User
public function rules() public function rules()
{ {
return [ return [
[['id', 'is_deleted', 'sort'], 'integer'], [['id', 'is_deleted', 'sort', 'last_logon'], 'integer'],
[['fio', 'status', 'email'], 'safe'], [['fio', 'status', 'email', 'fullName'], 'safe'],
]; ];
} }
...@@ -44,27 +44,27 @@ class UserSearch extends User ...@@ -44,27 +44,27 @@ class UserSearch extends User
{ {
$query = User::find(); $query = User::find();
$sort = new Sort([
'attributes' => [
'status' => [
'asc' => ['status' => SORT_ASC],
'desc' => ['status' => SORT_DESC],
'default' => SORT_DESC,
'label' => 'Статус',
],
],
]);
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => $query, '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); $this->load($params);
if (!$this->validate()) { if (!$this->validate()) {
...@@ -73,26 +73,21 @@ class UserSearch extends User ...@@ -73,26 +73,21 @@ class UserSearch extends User
return $dataProvider; return $dataProvider;
} }
$query->select(['*', "CONCAT(name, ' ', surname) as fullName"]);
if($this->fullName)
{
$query->andHaving([
'fullName' => $this->fullName,
]);
}
$query->andFilterWhere([ $query->andFilterWhere([
'id' => $this->id, 'id' => $this->id,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'sort' => $this->sort, '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; 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