Merge pull request #35 from apuc/sum_and_calendar

Sum and calendar
This commit is contained in:
kavalar 2020-01-29 12:48:34 +03:00 committed by GitHub
commit 0ec17ddf89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 353 additions and 58 deletions

View File

@ -6,6 +6,7 @@ use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use yii\helpers\Url;
/**
* Site controller
@ -18,20 +19,6 @@ class SiteController extends Controller
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error'],
'allow' => true,
],
[
'actions' => ['logout', 'index'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
@ -76,10 +63,14 @@ class SiteController extends Controller
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
if (\Yii::$app->user->can('secure')) {
return $this->goBack();
} else {
Yii::$app->user->logout();
return $this->redirect(Url::to('/card/user-card'));
}
} else {
$model->password = '';
return $this->render('login', [
'model' => $model,
]);

View File

@ -8,6 +8,7 @@ use common\models\UserCardAccesses;
use Yii;
use common\models\Accesses;
use app\modules\accesses\models\AccessesSearch;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -29,6 +30,15 @@ class AccessesController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}
@ -112,6 +122,15 @@ class AccessesController extends Controller
return $this->redirect(['index']);
}
public function actionCustomDelete($id)
{
$clean_id = str_replace('=', "", stristr($id, '='));
UserCardAccesses::deleteAll(['accesses_id' => $clean_id]);
Accesses::deleteAll(['id' => $clean_id]);
return $this->redirect(['index']);
}
/**
* Finds the Accesses model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.

View File

@ -43,7 +43,17 @@ $this->params['breadcrumbs'][] = $this->title;
// return $model->getProjectName();
// },
// ],
['class' => 'yii\grid\ActionColumn'],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'buttons' => [
'delete' => function ($data) {
return Html::a("<span class='glyphicon glyphicon-trash' aria-hidden='true'></span>",
['/accesses/accesses/custom-delete', 'id' => $data]);
},
],
],
// ['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -10,12 +10,39 @@ use common\models\FieldsValueNew;
use DateTime;
use Yii;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\db\Query;
class BalanceController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}
public function actionIndex()
{
$searchModel = new BalanceSearch();

View File

@ -6,6 +6,8 @@ use backend\modules\card\models\UserCardSearch;
use common\classes\Debug;
use Yii;
use yii\data\ArrayDataProvider;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
/**
@ -13,6 +15,30 @@ use yii\web\Controller;
*/
class CalendarController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}
/**
* Renders the index view for the module
* @return string

View File

@ -14,6 +14,7 @@ use backend\modules\card\models\UserCard;
use backend\modules\card\models\UserCardSearch;
use yii\data\ActiveDataProvider;
use yii\db\Expression;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -35,6 +36,15 @@ class UserCardController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}
@ -162,17 +172,6 @@ class UserCardController extends Controller
return $this->redirect(['index']);
}
/**
* Lists all UserCard models.
* @return mixed
*/
public function actionGenerate()
{
$massage = UserCard::generateUserForUserCard();
return $this->render('generate', ['massage' => $massage]);
}
/**
* Finds the UserCard model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.

View File

@ -161,8 +161,8 @@ class UserCard extends \common\models\UserCard
}
}
if ($user_card_array) return "Данные успешно сгенерированы";
else return "Нет данных для генерации";
if ($user_card_array) return "data generated successfully";
else return "no data to generate";
}
public static function getParameter($params, $key)

View File

@ -16,7 +16,6 @@ $this->params['breadcrumbs'][] = $this->title;
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Сгенерировать пользователей', ['generate'], ['class' => 'btn btn-success']) ?>
</p>
<?php

View File

@ -7,6 +7,7 @@ use Yii;
use backend\modules\company\models\Company;
use backend\modules\company\models\CompanySearch;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -28,6 +29,15 @@ class CompanyController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -9,6 +9,7 @@ use Yii;
use backend\modules\hh\models\Hh;
use backend\modules\hh\models\HhSearch;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -30,6 +31,15 @@ class HhController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -6,6 +6,7 @@ use common\models\Hh;
use Yii;
use backend\modules\hh\models\HhJob;
use backend\modules\hh\models\HhJobSearch;
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@ -28,6 +29,15 @@ class HhJobController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -6,6 +6,7 @@ use backend\modules\holiday\models\Holiday;
use backend\modules\holiday\models\HolidaySearch;
use common\classes\Debug;
use Yii;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@ -24,6 +25,15 @@ class HolidayController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -7,6 +7,8 @@ use Yii;
use backend\modules\notes\models\Note;
use common\models\FieldsValueNew;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@ -15,6 +17,30 @@ use yii\web\NotFoundHttpException;
*/
class NotesController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}
/**
* Renders the index view for the module
* @return string

View File

@ -11,6 +11,7 @@ use Yii;
use backend\modules\project\models\Project;
use backend\modules\project\models\ProjectSearch;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -32,6 +33,15 @@ class ProjectController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -7,6 +7,7 @@ use common\models\UseField;
use Yii;
use backend\modules\settings\models\AdditionalFields;
use backend\modules\settings\models\AdditionalFieldsSearch;
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@ -29,6 +30,15 @@ class AdditionalFieldsController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -5,6 +5,7 @@ namespace backend\modules\settings\controllers;
use Yii;
use backend\modules\settings\models\Position;
use backend\modules\settings\models\PositionSearch;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -26,6 +27,15 @@ class PositionController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -5,6 +5,7 @@ namespace backend\modules\settings\controllers;
use Yii;
use backend\modules\settings\models\Skill;
use backend\modules\settings\models\SkillSearch;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -26,6 +27,15 @@ class SkillController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -6,6 +6,7 @@ use common\models\UseStatus;
use Yii;
use backend\modules\settings\models\Status;
use backend\modules\settings\models\StatusSearch;
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@ -28,6 +29,15 @@ class StatusController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}

View File

@ -9,6 +9,12 @@ return [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
// 'itemFile' => '@common/components/rbac/items.php',
// 'assignmentFile' => '@common/components/rbac/assignments.php',
// 'ruleFile' => '@common/components/rbac/rules.php'
],
],
'controllerMap' => [
'elfinder' => [

View File

@ -40,6 +40,7 @@ class Accesses extends \yii\db\ActiveRecord
[['info'], 'string'],
[['_projects'], 'safe'],
[['_users'], 'safe'],
[['name', 'login', 'password', 'link', 'project', 'info'], 'required'],
];
}

View File

@ -0,0 +1,59 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "auth_assignment".
*
* @property string $item_name
* @property string $user_id
* @property int $created_at
*
* @property AuthItem $itemName
*/
class AuthAssignment extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'auth_assignment';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['item_name', 'user_id'], 'required'],
[['created_at'], 'integer'],
[['item_name', 'user_id'], 'string', 'max' => 64],
[['item_name', 'user_id'], 'unique', 'targetAttribute' => ['item_name', 'user_id']],
[['item_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['item_name' => 'name']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'item_name' => 'Item Name',
'user_id' => 'User ID',
'created_at' => 'Created At',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getItemName()
{
return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
}
}

View File

@ -6,6 +6,7 @@ use common\classes\Debug;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
/**

View File

@ -27,7 +27,7 @@
"nkovacs/yii2-datetimepicker": "*",
"mirocow/yii2-eav": "*",
"kartik-v/yii2-widget-fileinput": "^1.0",
"2amigos/yii2-file-upload-widget": "~1.0"
"2amigos/yii2-file-upload-widget": "~1.0",
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",

View File

@ -22,6 +22,12 @@ return [
],
],
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'class' => 'yii\web\User',
'enableSession' => false,
'enableAutoLogin' => false,
],
'log' => [
'targets' => [
[

View File

@ -0,0 +1,36 @@
<?php
namespace console\controllers;
use Yii;
use yii\console\Controller;
class RbacController extends Controller
{
public function actionInit()
{
$auth = Yii::$app->authManager;
$secure = $auth->createPermission('secure');
$secure->description = 'Admin panel';
$auth->add($secure);
$front = $auth->createPermission('front');
$front->description = 'Frontend';
$auth->add($front);
$user = $auth->createRole('user');
$auth->add($user);
$auth->addChild($user, $front);
$admin = $auth->createRole('admin');
$auth->add($admin);
$auth->addChild($admin, $secure);
$auth->addChild($admin, $user);
$auth->assign($user, 2);
$auth->assign($admin, 1);
}
}

View File

@ -4,6 +4,7 @@
namespace console\controllers;
use backend\modules\card\models\UserCard;
use Yii;
use yii\console\Controller;
@ -13,5 +14,11 @@ class SqlController extends Controller
{
$sql = "UPDATE user_card SET salary=REPLACE( `salary`, ' ', '' )";
Yii::$app->db->createCommand($sql)->execute();
echo "script completed successfully\n";
}
public function actionGenerateUser()
{
echo UserCard::generateUserForUserCard() . "\n";
}
}

View File

@ -1,6 +1,8 @@
<?php
namespace frontend\models;
use common\classes\Debug;
use Yii;
use yii\base\Model;
use common\models\User;
@ -52,6 +54,11 @@ class SignupForm extends Model
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
$user->save();
$auth = Yii::$app->authManager;
$authorRole = $auth->getRole('user');
$auth->assign($authorRole, $user->id);
return $user->save() ? $user : null;
}

View File

@ -33,9 +33,6 @@ use yii\helpers\ArrayHelper;
[
'data' => ArrayHelper::map(Skill::find()->all(), 'id', 'name'),
'options' => ['placeholder' => '...', 'class' => 'form-control', 'multiple' => true],
'pluginOptions' => [
'allowClear' => true
],
]
)->label('Навыки'); ?>
</div>

View File

@ -21,34 +21,11 @@ $this->title = 'Профиль';
'attributes' => [
['label' => 'ФИО', 'attribute' => 'fio',],
['label' => 'Email', 'attribute' => 'email',],
[
'attribute' => 'gender',
'value' => $model->gendersText,
],
['label' => 'Дата рождения', 'attribute' => 'dob',],
[
'attribute' => 'status',
'value' => $model->status0->name,
],
[
'attribute' => 'position_id',
'value' => (isset($model->position->name)) ? $model->position->name : 'Без должности',
],
[
'attribute' => 'Фото',
'format' => 'raw',
'value' => function ($model) {
return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']);
}
],
[
'attribute' => 'Резюме',
'format' => 'raw',
'value' => function ($model) {
return Html::a('Скачать', $model->resume, ['target' => '_blank']);
}
],
['label' => 'Добвлен', 'attribute' => 'created_at',],
],
]);
?>

11
package-lock.json generated Normal file
View File

@ -0,0 +1,11 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"sticky-table-headers": {
"version": "0.1.24",
"resolved": "https://registry.npmjs.org/sticky-table-headers/-/sticky-table-headers-0.1.24.tgz",
"integrity": "sha1-euofB5HKOgKwhgzYhe11ehrL84E="
}
}
}