first commit
This commit is contained in:
commit
9e8e98c379
35
.gitignore
vendored
Normal file
35
.gitignore
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
# yii console commands
|
||||
/yii
|
||||
/yii_test
|
||||
/yii_test.bat
|
||||
|
||||
# phpstorm project files
|
||||
.idea
|
||||
|
||||
# netbeans project files
|
||||
nbproject
|
||||
|
||||
# zend studio for eclipse project files
|
||||
.buildpath
|
||||
.project
|
||||
.settings
|
||||
|
||||
# windows thumbnail cache
|
||||
Thumbs.db
|
||||
|
||||
# composer vendor dir
|
||||
/vendor
|
||||
|
||||
# composer itself is not needed
|
||||
composer.phar
|
||||
|
||||
# Mac DS_Store Files
|
||||
.DS_Store
|
||||
|
||||
# phpunit itself is not needed
|
||||
phpunit.phar
|
||||
# local phpunit config
|
||||
/phpunit.xml
|
||||
|
||||
# vagrant runtime
|
||||
/.vagrant
|
19
.htaccess
Normal file
19
.htaccess
Normal file
@ -0,0 +1,19 @@
|
||||
php_value date.timezone Europe/Moscow
|
||||
AddDefaultCharset UTF-8
|
||||
# Mod_Autoindex
|
||||
<IfModule mod_autoindex.c>
|
||||
# Запрещаем просмотр содержимого папок
|
||||
Options -Indexes
|
||||
</IfModule>
|
||||
|
||||
# Mod_Rewrite
|
||||
<IfModule mod_rewrite.c>
|
||||
Options +SymLinksIfOwnerMatch
|
||||
# Включаем mod_rewrite
|
||||
RewriteEngine On
|
||||
IndexIgnore */*
|
||||
# Перенаправляем administrator на входной скрипт админки
|
||||
RewriteRule ^secure(.*)?$ /backend/web/$1 [L,PT]
|
||||
# Перенаправляем все запросы на входной скрипт
|
||||
RewriteRule ^([^/].*)?$ /frontend/web/$1
|
||||
</IfModule>
|
32
LICENSE.md
Normal file
32
LICENSE.md
Normal file
@ -0,0 +1,32 @@
|
||||
The Yii framework is free software. It is released under the terms of
|
||||
the following BSD License.
|
||||
|
||||
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Yii Software LLC nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
60
README.md
Normal file
60
README.md
Normal file
@ -0,0 +1,60 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/yiisoft" target="_blank">
|
||||
<img src="https://avatars0.githubusercontent.com/u/993323" height="100px">
|
||||
</a>
|
||||
<h1 align="center">Yii 2 Advanced Project Template</h1>
|
||||
<br>
|
||||
</p>
|
||||
|
||||
Yii 2 Advanced Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
|
||||
developing complex Web applications with multiple tiers.
|
||||
|
||||
The template includes three tiers: front end, back end, and console, each of which
|
||||
is a separate Yii application.
|
||||
|
||||
The template is designed to work in a team development environment. It supports
|
||||
deploying the application in different environments.
|
||||
|
||||
Documentation is at [docs/guide/README.md](docs/guide/README.md).
|
||||
|
||||
[![Latest Stable Version](https://img.shields.io/packagist/v/yiisoft/yii2-app-advanced.svg)](https://packagist.org/packages/yiisoft/yii2-app-advanced)
|
||||
[![Total Downloads](https://img.shields.io/packagist/dt/yiisoft/yii2-app-advanced.svg)](https://packagist.org/packages/yiisoft/yii2-app-advanced)
|
||||
[![Build Status](https://travis-ci.org/yiisoft/yii2-app-advanced.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-app-advanced)
|
||||
|
||||
DIRECTORY STRUCTURE
|
||||
-------------------
|
||||
|
||||
```
|
||||
common
|
||||
config/ contains shared configurations
|
||||
mail/ contains view files for e-mails
|
||||
models/ contains model classes used in both backend and frontend
|
||||
tests/ contains tests for common classes
|
||||
console
|
||||
config/ contains console configurations
|
||||
controllers/ contains console controllers (commands)
|
||||
migrations/ contains database migrations
|
||||
models/ contains console-specific model classes
|
||||
runtime/ contains files generated during runtime
|
||||
backend
|
||||
assets/ contains application assets such as JavaScript and CSS
|
||||
config/ contains backend configurations
|
||||
controllers/ contains Web controller classes
|
||||
models/ contains backend-specific model classes
|
||||
runtime/ contains files generated during runtime
|
||||
tests/ contains tests for backend application
|
||||
views/ contains view files for the Web application
|
||||
web/ contains the entry script and Web resources
|
||||
frontend
|
||||
assets/ contains application assets such as JavaScript and CSS
|
||||
config/ contains frontend configurations
|
||||
controllers/ contains Web controller classes
|
||||
models/ contains frontend-specific model classes
|
||||
runtime/ contains files generated during runtime
|
||||
tests/ contains tests for frontend application
|
||||
views/ contains view files for the Web application
|
||||
web/ contains the entry script and Web resources
|
||||
widgets/ contains frontend widgets
|
||||
vendor/ contains dependent 3rd-party packages
|
||||
environments/ contains environment-based overrides
|
||||
```
|
77
Vagrantfile
vendored
Normal file
77
Vagrantfile
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
require 'yaml'
|
||||
require 'fileutils'
|
||||
|
||||
required_plugins = %w( vagrant-hostmanager vagrant-vbguest )
|
||||
required_plugins.each do |plugin|
|
||||
exec "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
|
||||
end
|
||||
|
||||
domains = {
|
||||
frontend: 'y2aa-frontend.test',
|
||||
backend: 'y2aa-backend.test'
|
||||
}
|
||||
|
||||
config = {
|
||||
local: './vagrant/config/vagrant-local.yml',
|
||||
example: './vagrant/config/vagrant-local.example.yml'
|
||||
}
|
||||
|
||||
# copy config from example if local config not exists
|
||||
FileUtils.cp config[:example], config[:local] unless File.exist?(config[:local])
|
||||
# read config
|
||||
options = YAML.load_file config[:local]
|
||||
|
||||
# check github token
|
||||
if options['github_token'].nil? || options['github_token'].to_s.length != 40
|
||||
puts "You must place REAL GitHub token into configuration:\n/yii2-app-advanced/vagrant/config/vagrant-local.yml"
|
||||
exit
|
||||
end
|
||||
|
||||
# vagrant configurate
|
||||
Vagrant.configure(2) do |config|
|
||||
# select the box
|
||||
config.vm.box = 'bento/ubuntu-16.04'
|
||||
|
||||
# should we ask about box updates?
|
||||
config.vm.box_check_update = options['box_check_update']
|
||||
|
||||
config.vm.provider 'virtualbox' do |vb|
|
||||
# machine cpus count
|
||||
vb.cpus = options['cpus']
|
||||
# machine memory size
|
||||
vb.memory = options['memory']
|
||||
# machine name (for VirtualBox UI)
|
||||
vb.name = options['machine_name']
|
||||
end
|
||||
|
||||
# machine name (for vagrant console)
|
||||
config.vm.define options['machine_name']
|
||||
|
||||
# machine name (for guest machine console)
|
||||
config.vm.hostname = options['machine_name']
|
||||
|
||||
# network settings
|
||||
config.vm.network 'private_network', ip: options['ip']
|
||||
|
||||
# sync: folder 'yii2-app-advanced' (host machine) -> folder '/app' (guest machine)
|
||||
config.vm.synced_folder './', '/app', owner: 'vagrant', group: 'vagrant'
|
||||
|
||||
# disable folder '/vagrant' (guest machine)
|
||||
config.vm.synced_folder '.', '/vagrant', disabled: true
|
||||
|
||||
# hosts settings (host machine)
|
||||
config.vm.provision :hostmanager
|
||||
config.hostmanager.enabled = true
|
||||
config.hostmanager.manage_host = true
|
||||
config.hostmanager.ignore_private_ip = false
|
||||
config.hostmanager.include_offline = true
|
||||
config.hostmanager.aliases = domains.values
|
||||
|
||||
# provisioners
|
||||
config.vm.provision 'shell', path: './vagrant/provision/once-as-root.sh', args: [options['timezone']]
|
||||
config.vm.provision 'shell', path: './vagrant/provision/once-as-vagrant.sh', args: [options['github_token']], privileged: false
|
||||
config.vm.provision 'shell', path: './vagrant/provision/always-as-root.sh', run: 'always'
|
||||
|
||||
# post-install message (vagrant console)
|
||||
config.vm.post_up_message = "Frontend URL: http://#{domains[:frontend]}\nBackend URL: http://#{domains[:backend]}"
|
||||
end
|
23
backend/assets/AppAsset.php
Normal file
23
backend/assets/AppAsset.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace backend\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
/**
|
||||
* Main backend application asset bundle.
|
||||
*/
|
||||
class AppAsset extends AssetBundle
|
||||
{
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
'css/site.css',
|
||||
];
|
||||
public $js = [
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
}
|
15
backend/codeception.yml
Normal file
15
backend/codeception.yml
Normal file
@ -0,0 +1,15 @@
|
||||
namespace: backend\tests
|
||||
actor_suffix: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
output: tests/_output
|
||||
data: tests/_data
|
||||
support: tests/_support
|
||||
settings:
|
||||
bootstrap: _bootstrap.php
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
modules:
|
||||
config:
|
||||
Yii2:
|
||||
configFile: 'config/test-local.php'
|
3
backend/config/.gitignore
vendored
Normal file
3
backend/config/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
main-local.php
|
||||
params-local.php
|
||||
test-local.php
|
1
backend/config/bootstrap.php
Normal file
1
backend/config/bootstrap.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
64
backend/config/main.php
Normal file
64
backend/config/main.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
$params = array_merge(
|
||||
require __DIR__ . '/../../common/config/params.php',
|
||||
require __DIR__ . '/../../common/config/params-local.php',
|
||||
require __DIR__ . '/params.php',
|
||||
require __DIR__ . '/params-local.php'
|
||||
);
|
||||
|
||||
return [
|
||||
'id' => 'app-backend',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'controllerNamespace' => 'backend\controllers',
|
||||
'bootstrap' => ['log'],
|
||||
|
||||
'modules' => [
|
||||
'status' => [
|
||||
'class' => 'backend\modules\status\Status',
|
||||
],
|
||||
'fields' => [
|
||||
'class' => 'backend\modules\fields\Fields',
|
||||
],
|
||||
'card' => [
|
||||
'class' => 'backend\modules\card\Card',
|
||||
],
|
||||
'project' => [
|
||||
'class' => 'backend\modules\project\Project',
|
||||
],
|
||||
],
|
||||
'components' => [
|
||||
'request' => [
|
||||
'csrfParam' => '_csrf-backend',
|
||||
'baseUrl' => '/secure',
|
||||
],
|
||||
'user' => [
|
||||
'identityClass' => 'common\models\User',
|
||||
'enableAutoLogin' => true,
|
||||
'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
|
||||
],
|
||||
'session' => [
|
||||
// this is the name of the session cookie used for login on the backend
|
||||
'name' => 'advanced-backend',
|
||||
],
|
||||
'log' => [
|
||||
'traceLevel' => YII_DEBUG ? 3 : 0,
|
||||
'targets' => [
|
||||
[
|
||||
'class' => 'yii\log\FileTarget',
|
||||
'levels' => ['error', 'warning'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'errorHandler' => [
|
||||
'errorAction' => 'site/error',
|
||||
],
|
||||
'urlManager' => [
|
||||
'enablePrettyUrl' => true,
|
||||
'showScriptName' => false,
|
||||
'rules' => [
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
'params' => $params,
|
||||
];
|
4
backend/config/params.php
Normal file
4
backend/config/params.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
];
|
12
backend/config/test.php
Normal file
12
backend/config/test.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => 'app-backend-tests',
|
||||
'components' => [
|
||||
'assetManager' => [
|
||||
'basePath' => __DIR__ . '/../web/assets',
|
||||
],
|
||||
'urlManager' => [
|
||||
'showScriptName' => true,
|
||||
],
|
||||
],
|
||||
];
|
100
backend/controllers/SiteController.php
Normal file
100
backend/controllers/SiteController.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\filters\AccessControl;
|
||||
use common\models\LoginForm;
|
||||
|
||||
/**
|
||||
* Site controller
|
||||
*/
|
||||
class SiteController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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' => [
|
||||
'logout' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
'error' => [
|
||||
'class' => 'yii\web\ErrorAction',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays homepage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Login action.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function actionLogin()
|
||||
{
|
||||
if (!Yii::$app->user->isGuest) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
$model = new LoginForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||
return $this->goBack();
|
||||
} else {
|
||||
$model->password = '';
|
||||
|
||||
return $this->render('login', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout action.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function actionLogout()
|
||||
{
|
||||
Yii::$app->user->logout();
|
||||
|
||||
return $this->goHome();
|
||||
}
|
||||
}
|
1
backend/models/.gitkeep
Normal file
1
backend/models/.gitkeep
Normal file
@ -0,0 +1 @@
|
||||
*
|
24
backend/modules/card/Card.php
Normal file
24
backend/modules/card/Card.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\card;
|
||||
|
||||
/**
|
||||
* card module definition class
|
||||
*/
|
||||
class Card extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\card\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
138
backend/modules/card/controllers/UserCardController.php
Normal file
138
backend/modules/card/controllers/UserCardController.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\card\controllers;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\FieldsValue;
|
||||
use Yii;
|
||||
use backend\modules\card\models\UserCard;
|
||||
use backend\modules\card\models\UserCardSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* UserCardController implements the CRUD actions for UserCard model.
|
||||
*/
|
||||
class UserCardController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all UserCard models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new UserCardSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single UserCard model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => FieldsValue::find()->where(['card_id' => $id])->orderBy('order'),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'modelFildValue' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new UserCard model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new UserCard();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing UserCard model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing UserCard model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the UserCard model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return UserCard the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = UserCard::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
57
backend/modules/card/models/UserCard.php
Normal file
57
backend/modules/card/models/UserCard.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\card\models;
|
||||
|
||||
use common\models\FieldsValue;
|
||||
|
||||
class UserCard extends \common\models\UserCard
|
||||
{
|
||||
public $fields;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$fieldValue = FieldsValue::find()->where(
|
||||
[
|
||||
'card_id' => \Yii::$app->request->get('id'),
|
||||
'project_id' => null,
|
||||
])
|
||||
->all();
|
||||
$array = [];
|
||||
if(!empty($fieldValue)){
|
||||
foreach ($fieldValue as $item){
|
||||
array_push($array, ['field_id' => $item->field_id, 'value' => $item->value, 'order' => $item->order]);
|
||||
}
|
||||
$this->fields = $array;
|
||||
}
|
||||
else{
|
||||
$this->fields = [
|
||||
[
|
||||
'field_id' => null,
|
||||
'value' => null,
|
||||
'order' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('UserCard');
|
||||
|
||||
FieldsValue::deleteAll(['card_id' => $this->id]);
|
||||
|
||||
foreach ( $post['fields'] as $item) {
|
||||
$fildsValue = new FieldsValue();
|
||||
$fildsValue->field_id = $item['field_id'];
|
||||
$fildsValue->value = $item['value'];
|
||||
$fildsValue->order = $item['order'];
|
||||
$fildsValue->card_id = $this->id;
|
||||
|
||||
$fildsValue->save();
|
||||
}
|
||||
|
||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
77
backend/modules/card/models/UserCardSearch.php
Normal file
77
backend/modules/card/models/UserCardSearch.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\card\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\card\models\UserCard;
|
||||
|
||||
/**
|
||||
* UserCardSearch represents the model behind the search form of `backend\modules\card\models\UserCard`.
|
||||
*/
|
||||
class UserCardSearch extends UserCard
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'gender', 'status'], 'integer'],
|
||||
[['fio', 'passport', 'photo', 'email', 'dob', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = UserCard::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,
|
||||
'gender' => $this->gender,
|
||||
'dob' => $this->dob,
|
||||
'status' => $this->status,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'fio', $this->fio])
|
||||
->andFilterWhere(['like', 'passport', $this->passport])
|
||||
->andFilterWhere(['like', 'photo', $this->photo])
|
||||
->andFilterWhere(['like', 'email', $this->email]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
148
backend/modules/card/views/user-card/_form.php
Normal file
148
backend/modules/card/views/user-card/_form.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
use mihaildev\elfinder\InputFile;
|
||||
use unclead\multipleinput\MultipleInput;
|
||||
use unclead\multipleinput\examples\models\ExampleModel;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCard */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="user-card-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'fio')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'passport')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="padding-bottom: 15px">
|
||||
<div class="imgUpload col-xs-6">
|
||||
<div class="media__upload_img"><img src="<?= $model->photo; ?>" width="100px"/></div>
|
||||
<?php
|
||||
echo InputFile::widget([
|
||||
'language' => 'ru',
|
||||
'controller' => 'elfinder',
|
||||
// вставляем название контроллера, по умолчанию равен elfinder
|
||||
'filter' => 'image',
|
||||
// фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
|
||||
'name' => 'UserCard[photo]',
|
||||
'id' => 'usercard-photo',
|
||||
'template' => '<label>Аватар</label><div class="input-group">{input}<span class="span-btn">{button}</span></div>',
|
||||
'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
|
||||
'buttonOptions' => ['class' => 'btn btn-primary'],
|
||||
'value' => $model->photo,
|
||||
'buttonName' => 'Выбрать изображение',
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<!--<div class="media__upload_img"><img src="<?/*= $model->photo; */?>" width="100px"/></div>-->
|
||||
<?php
|
||||
echo InputFile::widget([
|
||||
'language' => 'ru',
|
||||
'controller' => 'elfinder',
|
||||
// вставляем название контроллера, по умолчанию равен elfinder
|
||||
'filter' => ['image','application/zip','application/pdf','application/msword','application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
// фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
|
||||
'name' => 'UserCard[resume]',
|
||||
'id' => 'usercard-resume',
|
||||
'template' => '<label>Резюме</label><div class="input-group">{input}<span class="span-btn">{button}</span></div>',
|
||||
'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
|
||||
'buttonOptions' => ['class' => 'btn btn-primary'],
|
||||
'value' => $model->photo,
|
||||
'buttonName' => 'Выбрать резюме',
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'gender')->dropDownList($model->genders,
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'dob')->input('date',
|
||||
[
|
||||
'placeholder' => 'Zadejte svůj Datum narození',
|
||||
'language' => 'en',
|
||||
"data-format" => "DD MMMM YYYY",
|
||||
|
||||
]) ?>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'status')
|
||||
->dropDownList(\yii\helpers\ArrayHelper::map(
|
||||
\common\models\Status::find()
|
||||
->joinWith('useStatuses')
|
||||
->where(['`use_status`.`use`' => \common\models\UseStatus::USE_PROFILE])->all(), 'id', 'name'),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<?= $form->field($model, 'fields')->widget(MultipleInput::class, [
|
||||
|
||||
'columns' => [
|
||||
[
|
||||
'name' => 'field_id',
|
||||
'type' => 'dropDownList',
|
||||
'title' => 'Поле',
|
||||
'defaultValue' => null,
|
||||
'items' => \yii\helpers\ArrayHelper::map(\backend\modules\fields\models\AdditionalFields::find()
|
||||
->joinWith('useFields')
|
||||
->where(['`use_field`.`use`' => \common\models\UseStatus::USE_PROFILE])
|
||||
->all(),
|
||||
'id', 'name'),
|
||||
'options' => ['prompt' => 'Выберите']
|
||||
],
|
||||
[
|
||||
'name' => 'value',
|
||||
'title' => 'Значение',
|
||||
'enableError' => true,
|
||||
'options' => [
|
||||
'class' => 'input-priority'
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'order',
|
||||
'title' => 'Приоритет',
|
||||
'enableError' => true,
|
||||
'options' => [
|
||||
'class' => 'input-priority'
|
||||
]
|
||||
]
|
||||
]
|
||||
])->label('Дополнительно');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
45
backend/modules/card/views/user-card/_search.php
Normal file
45
backend/modules/card/views/user-card/_search.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCardSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="user-card-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'fio') ?>
|
||||
|
||||
<?= $form->field($model, 'passport') ?>
|
||||
|
||||
<?= $form->field($model, 'photo') ?>
|
||||
|
||||
<?= $form->field($model, 'email') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'gender') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'dob') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'status') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
16
backend/modules/card/views/user-card/create.php
Normal file
16
backend/modules/card/views/user-card/create.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCard */
|
||||
|
||||
$this->title = 'Новый профиль';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Профили', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-card-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
39
backend/modules/card/views/user-card/index.php
Normal file
39
backend/modules/card/views/user-card/index.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\card\models\UserCardSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Профили';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-card-index">
|
||||
|
||||
<p>
|
||||
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id',
|
||||
'fio',
|
||||
'passport',
|
||||
'photo',
|
||||
'email:email',
|
||||
//'gender',
|
||||
//'dob',
|
||||
//'status',
|
||||
//'created_at',
|
||||
//'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
21
backend/modules/card/views/user-card/update.php
Normal file
21
backend/modules/card/views/user-card/update.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCard */
|
||||
|
||||
$this->title = 'Update User Card: ' . $model->id;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Cards', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="user-card-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
68
backend/modules/card/views/user-card/view.php
Normal file
68
backend/modules/card/views/user-card/view.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCard */
|
||||
|
||||
$this->title = $model->fio;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Cards', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-card-view">
|
||||
|
||||
<p>
|
||||
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'fio',
|
||||
'passport',
|
||||
[
|
||||
'label' => 'Photo',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']);
|
||||
}
|
||||
],
|
||||
[
|
||||
'label' => 'Resume',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return Html::a('Скачать', $model->resume, ['target' => '_blank']);
|
||||
}
|
||||
],
|
||||
[
|
||||
'label' => 'gender',
|
||||
'value' => $model->gendersText,
|
||||
],
|
||||
|
||||
'email:email',
|
||||
|
||||
'dob',
|
||||
[
|
||||
'label' => 'status',
|
||||
'value' => $model->status0->name,
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<h2>Дополнительные сведения</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $modelFildValue,
|
||||
'layout'=>"{items}",
|
||||
'columns' => [
|
||||
'field.name:text:Поле',
|
||||
'value',
|
||||
],
|
||||
]); ?>
|
||||
|
||||
|
||||
</div>
|
24
backend/modules/fields/Fields.php
Normal file
24
backend/modules/fields/Fields.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\fields;
|
||||
|
||||
/**
|
||||
* fields module definition class
|
||||
*/
|
||||
class Fields extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\fields\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\fields\controllers;
|
||||
|
||||
use Yii;
|
||||
use backend\modules\fields\models\AdditionalFields;
|
||||
use backend\modules\fields\models\AdditionalFieldsSearch;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* AdditionalFieldsController implements the CRUD actions for AdditionalFields model.
|
||||
*/
|
||||
class AdditionalFieldsController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all AdditionalFields models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new AdditionalFieldsSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single AdditionalFields model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AdditionalFields model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new AdditionalFields();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing AdditionalFields model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
$model->use = ArrayHelper::getColumn(
|
||||
\common\models\UseField::find()->where(['field_id' => $model->id])->asArray()->all(),
|
||||
'use');
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing AdditionalFields model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the AdditionalFields model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return AdditionalFields the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = AdditionalFields::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
23
backend/modules/fields/models/AdditionalFields.php
Normal file
23
backend/modules/fields/models/AdditionalFields.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\fields\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\UseField;
|
||||
|
||||
class AdditionalFields extends \common\models\AdditionalFields
|
||||
{
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
UseField::deleteAll(['field_id' => $this->id]);
|
||||
|
||||
foreach ($this->use as $item) {
|
||||
$useField = new UseField();
|
||||
$useField->field_id = $this->id;
|
||||
$useField->use = $item;
|
||||
|
||||
$useField->save();
|
||||
}
|
||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
68
backend/modules/fields/models/AdditionalFieldsSearch.php
Normal file
68
backend/modules/fields/models/AdditionalFieldsSearch.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\fields\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
|
||||
/**
|
||||
* AdditionalFieldsSearch represents the model behind the search form of `backend\modules\card\models\AdditionalFields`.
|
||||
*/
|
||||
class AdditionalFieldsSearch extends AdditionalFields
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id'], 'integer'],
|
||||
[['name'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = AdditionalFields::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,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
25
backend/modules/fields/views/additional-fields/_form.php
Normal file
25
backend/modules/fields/views/additional-fields/_form.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\fields\models\AdditionalFields */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="additional-fields-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'use')->checkboxList((new \common\models\UseField())->statuses); ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
29
backend/modules/fields/views/additional-fields/_search.php
Normal file
29
backend/modules/fields/views/additional-fields/_search.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\AdditionalFieldsSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="additional-fields-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'name') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
19
backend/modules/fields/views/additional-fields/create.php
Normal file
19
backend/modules/fields/views/additional-fields/create.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\AdditionalFields */
|
||||
|
||||
$this->title = 'Добавление поля';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Дополнительные поля', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="additional-fields-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
33
backend/modules/fields/views/additional-fields/index.php
Normal file
33
backend/modules/fields/views/additional-fields/index.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\card\models\AdditionalFieldsSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Дополнительные поля';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="additional-fields-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id',
|
||||
'name',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
19
backend/modules/fields/views/additional-fields/update.php
Normal file
19
backend/modules/fields/views/additional-fields/update.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\AdditionalFields */
|
||||
|
||||
$this->title = 'Редактирование: ' . $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Additional Fields', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="additional-fields-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
36
backend/modules/fields/views/additional-fields/view.php
Normal file
36
backend/modules/fields/views/additional-fields/view.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\AdditionalFields */
|
||||
|
||||
$this->title = $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Additional Fields', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="additional-fields-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => 'Are you sure you want to delete this item?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
'name',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
24
backend/modules/project/Project.php
Normal file
24
backend/modules/project/Project.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\project;
|
||||
|
||||
/**
|
||||
* project module definition class
|
||||
*/
|
||||
class Project extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\project\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
146
backend/modules/project/controllers/ProjectController.php
Normal file
146
backend/modules/project/controllers/ProjectController.php
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\project\controllers;
|
||||
|
||||
use common\models\FieldsValue;
|
||||
use common\models\ProjectUser;
|
||||
use Yii;
|
||||
use backend\modules\project\models\Project;
|
||||
use backend\modules\project\models\ProjectSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* ProjectController implements the CRUD actions for Project model.
|
||||
*/
|
||||
class ProjectController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Project models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new ProjectSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Project model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => FieldsValue::find()->where(['project_id' => $id])->orderBy('order'),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
],
|
||||
]);
|
||||
|
||||
$dataProviderUser = new ActiveDataProvider([
|
||||
'query' => ProjectUser::find()->where(['project_id' => $id]),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'modelFildValue' => $dataProvider,
|
||||
'modelUser' => $dataProviderUser,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Project model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Project();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Project model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Project model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Project model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Project the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Project::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
79
backend/modules/project/models/Project.php
Normal file
79
backend/modules/project/models/Project.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\project\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\FieldsValue;
|
||||
use common\models\ProjectUser;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
class Project extends \common\models\Project
|
||||
{
|
||||
public $fields;
|
||||
public $user;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$fieldValue = FieldsValue::find()
|
||||
->where(
|
||||
[
|
||||
'project_id' => \Yii::$app->request->get('id'),
|
||||
'card_id' => null,
|
||||
])
|
||||
->all();
|
||||
$array = [];
|
||||
if (!empty($fieldValue)) {
|
||||
foreach ($fieldValue as $item) {
|
||||
array_push($array, ['field_id' => $item->field_id, 'value' => $item->value, 'order' => $item->order]);
|
||||
}
|
||||
$this->fields = $array;
|
||||
} else {
|
||||
$this->fields = [
|
||||
[
|
||||
'field_id' => null,
|
||||
'value' => null,
|
||||
'order' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$user = ArrayHelper::getColumn(ProjectUser::find()->where(['project_id' => \Yii::$app->request->get('id')])->all(),
|
||||
'card_id');
|
||||
|
||||
if (!empty($user)) {
|
||||
$this->user = $user;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('Project');
|
||||
|
||||
FieldsValue::deleteAll(['project_id' => $this->id]);
|
||||
|
||||
foreach ($post['fields'] as $item) {
|
||||
$fildsValue = new FieldsValue();
|
||||
$fildsValue->field_id = $item['field_id'];
|
||||
$fildsValue->value = $item['value'];
|
||||
$fildsValue->order = $item['order'];
|
||||
$fildsValue->project_id = $this->id;
|
||||
|
||||
$fildsValue->save();
|
||||
}
|
||||
|
||||
ProjectUser::deleteAll(['project_id' => $this->id]);
|
||||
|
||||
foreach ($post['user'] as $item) {
|
||||
$prUser = new ProjectUser();
|
||||
$prUser->project_id = $this->id;
|
||||
$prUser->card_id = $item;
|
||||
|
||||
$prUser->save();
|
||||
}
|
||||
|
||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
72
backend/modules/project/models/ProjectSearch.php
Normal file
72
backend/modules/project/models/ProjectSearch.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\project\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\project\models\Project;
|
||||
|
||||
/**
|
||||
* ProjectSearch represents the model behind the search form of `backend\modules\project\models\Project`.
|
||||
*/
|
||||
class ProjectSearch extends Project
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id'], 'integer'],
|
||||
[['name', 'description', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Project::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,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name])
|
||||
->andFilterWhere(['like', 'description', $this->description]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
77
backend/modules/project/views/project/_form.php
Normal file
77
backend/modules/project/views/project/_form.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
use kartik\select2\Select2;
|
||||
use unclead\multipleinput\MultipleInput;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\project\models\Project */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="project-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<?= $form->field($model, 'fields')->widget(MultipleInput::class, [
|
||||
|
||||
'columns' => [
|
||||
[
|
||||
'name' => 'field_id',
|
||||
'type' => 'dropDownList',
|
||||
'title' => 'Поле',
|
||||
'defaultValue' => null,
|
||||
'items' => \yii\helpers\ArrayHelper::map(\backend\modules\fields\models\AdditionalFields::find()
|
||||
->joinWith('useFields')
|
||||
->where(['`use_field`.`use`' => \common\models\UseStatus::USE_PROJECT])
|
||||
->all(),
|
||||
'id', 'name'),
|
||||
'options' => ['prompt' => 'Выберите']
|
||||
],
|
||||
[
|
||||
'name' => 'value',
|
||||
'title' => 'Значение',
|
||||
'enableError' => true,
|
||||
'options' => [
|
||||
'class' => 'input-priority'
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'order',
|
||||
'title' => 'Приоритет',
|
||||
'enableError' => true,
|
||||
'options' => [
|
||||
'class' => 'input-priority'
|
||||
]
|
||||
]
|
||||
]
|
||||
])->label('Дополнительно');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $form->field($model, 'user')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\UserCard::find()->all(),'id', 'fio'),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control', 'multiple' => true],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]
|
||||
); ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
35
backend/modules/project/views/project/_search.php
Normal file
35
backend/modules/project/views/project/_search.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\project\models\ProjectSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="project-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'name') ?>
|
||||
|
||||
<?= $form->field($model, 'description') ?>
|
||||
|
||||
<?= $form->field($model, 'created_at') ?>
|
||||
|
||||
<?= $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
19
backend/modules/project/views/project/create.php
Normal file
19
backend/modules/project/views/project/create.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\project\models\Project */
|
||||
|
||||
$this->title = 'Создать';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Проекты', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="project-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
36
backend/modules/project/views/project/index.php
Normal file
36
backend/modules/project/views/project/index.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\project\models\ProjectSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Проекты';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="project-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id',
|
||||
'name',
|
||||
'description:ntext',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
18
backend/modules/project/views/project/update.php
Normal file
18
backend/modules/project/views/project/update.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\project\models\Project */
|
||||
|
||||
$this->title = 'Редактирование: ' . $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Проекты', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
|
||||
?>
|
||||
<div class="project-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
80
backend/modules/project/views/project/view.php
Normal file
80
backend/modules/project/views/project/view.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\project\models\Project */
|
||||
|
||||
$this->title = $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Projects', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="project-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => 'Are you sure you want to delete this item?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
'name',
|
||||
'description:ntext',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
<h2>Дополнительные сведения</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $modelFildValue,
|
||||
'layout'=>"{items}",
|
||||
'columns' => [
|
||||
'field.name:text:Поле',
|
||||
'value',
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<h2>Пользователи проекта</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $modelUser,
|
||||
'layout'=>"{items}",
|
||||
'columns' => [
|
||||
'card.fio:text:ФИО',
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update}',
|
||||
'buttons' => [
|
||||
'update' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-pencil"></span>',
|
||||
['/card/user-card/update', 'id' => $model->id],
|
||||
['target' => '_blank']
|
||||
);
|
||||
},
|
||||
'view' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-eye-open"></span>',
|
||||
['/card/user-card/view', 'id' => $model->id],
|
||||
['target' => '_blank']
|
||||
);
|
||||
},
|
||||
],
|
||||
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
24
backend/modules/status/Status.php
Normal file
24
backend/modules/status/Status.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\status;
|
||||
|
||||
/**
|
||||
* status module definition class
|
||||
*/
|
||||
class Status extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\status\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
130
backend/modules/status/controllers/StatusController.php
Normal file
130
backend/modules/status/controllers/StatusController.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\status\controllers;
|
||||
|
||||
use Yii;
|
||||
use backend\modules\status\models\Status;
|
||||
use backend\modules\status\models\StatusSearch;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* StatusController implements the CRUD actions for Status model.
|
||||
*/
|
||||
class StatusController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Status models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new StatusSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Status model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Status model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Status();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Status model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
$model->use = ArrayHelper::getColumn(
|
||||
\common\models\UseStatus::find()->where(['status_id' => $model->id])->asArray()->all(),
|
||||
'use');
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Status model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Status model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Status the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Status::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
22
backend/modules/status/models/Status.php
Normal file
22
backend/modules/status/models/Status.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\status\models;
|
||||
|
||||
use common\models\UseStatus;
|
||||
|
||||
class Status extends \common\models\Status
|
||||
{
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
UseStatus::deleteAll(['status_id' => $this->id]);
|
||||
foreach ($this->use as $item) {
|
||||
$useStatus = new UseStatus();
|
||||
$useStatus->status_id = $this->id;
|
||||
$useStatus->use = $item;
|
||||
|
||||
$useStatus->save();
|
||||
}
|
||||
|
||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
69
backend/modules/status/models/StatusSearch.php
Normal file
69
backend/modules/status/models/StatusSearch.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\status\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\status\models\Status;
|
||||
|
||||
/**
|
||||
* StatusSearch represents the model behind the search form of `backend\modules\status\models\Status`.
|
||||
*/
|
||||
class StatusSearch extends Status
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id'], 'integer'],
|
||||
[['name'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Status::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,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
26
backend/modules/status/views/status/_form.php
Normal file
26
backend/modules/status/views/status/_form.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\status\models\Status */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
|
||||
?>
|
||||
|
||||
<div class="status-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'use')->checkboxList((new \common\models\UseStatus())->statuses); ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
29
backend/modules/status/views/status/_search.php
Normal file
29
backend/modules/status/views/status/_search.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\status\models\StatusSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="status-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'name') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
16
backend/modules/status/views/status/create.php
Normal file
16
backend/modules/status/views/status/create.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\status\models\Status */
|
||||
|
||||
$this->title = 'Добавить статус';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Статусы', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="status-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
33
backend/modules/status/views/status/index.php
Normal file
33
backend/modules/status/views/status/index.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\status\models\StatusSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Statuses';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="status-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Create Status', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id',
|
||||
'name',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
17
backend/modules/status/views/status/update.php
Normal file
17
backend/modules/status/views/status/update.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\status\models\Status */
|
||||
|
||||
$this->title = 'Update Status: ' . $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Statuses', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="status-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
36
backend/modules/status/views/status/view.php
Normal file
36
backend/modules/status/views/status/view.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\status\models\Status */
|
||||
|
||||
$this->title = $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Statuses', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="status-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => 'Are you sure you want to delete this item?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
'name',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
2
backend/runtime/.gitignore
vendored
Normal file
2
backend/runtime/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
9
backend/tests/_bootstrap.php
Normal file
9
backend/tests/_bootstrap.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__.'/../../');
|
||||
|
||||
require_once YII_APP_BASE_PATH . '/vendor/autoload.php';
|
||||
require_once YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php';
|
||||
require_once YII_APP_BASE_PATH . '/common/config/bootstrap.php';
|
||||
require_once __DIR__ . '/../config/bootstrap.php';
|
0
backend/tests/_data/.gitignore
vendored
Normal file
0
backend/tests/_data/.gitignore
vendored
Normal file
13
backend/tests/_data/login_data.php
Normal file
13
backend/tests/_data/login_data.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
return [
|
||||
[
|
||||
'username' => 'erau',
|
||||
'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
|
||||
// password_0
|
||||
'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
|
||||
'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
|
||||
'created_at' => '1392559490',
|
||||
'updated_at' => '1392559490',
|
||||
'email' => 'sfriesen@jenkins.info',
|
||||
],
|
||||
];
|
2
backend/tests/_output/.gitignore
vendored
Normal file
2
backend/tests/_output/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
1
backend/tests/_support/.gitignore
vendored
Normal file
1
backend/tests/_support/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
_generated
|
25
backend/tests/_support/FunctionalTester.php
Normal file
25
backend/tests/_support/FunctionalTester.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace backend\tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class FunctionalTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\FunctionalTesterActions;
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
25
backend/tests/_support/UnitTester.php
Normal file
25
backend/tests/_support/UnitTester.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace backend\tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class UnitTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\UnitTesterActions;
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
5
backend/tests/functional.suite.yml
Normal file
5
backend/tests/functional.suite.yml
Normal file
@ -0,0 +1,5 @@
|
||||
suite_namespace: backend\tests\functional
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Yii2
|
44
backend/tests/functional/LoginCest.php
Normal file
44
backend/tests/functional/LoginCest.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace backend\tests\functional;
|
||||
|
||||
use backend\tests\FunctionalTester;
|
||||
use common\fixtures\UserFixture;
|
||||
|
||||
/**
|
||||
* Class LoginCest
|
||||
*/
|
||||
class LoginCest
|
||||
{
|
||||
/**
|
||||
* Load fixtures before db transaction begin
|
||||
* Called in _before()
|
||||
* @see \Codeception\Module\Yii2::_before()
|
||||
* @see \Codeception\Module\Yii2::loadFixtures()
|
||||
* @return array
|
||||
*/
|
||||
public function _fixtures()
|
||||
{
|
||||
return [
|
||||
'user' => [
|
||||
'class' => UserFixture::className(),
|
||||
'dataFile' => codecept_data_dir() . 'login_data.php'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FunctionalTester $I
|
||||
*/
|
||||
public function loginUser(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnPage('/site/login');
|
||||
$I->fillField('Username', 'erau');
|
||||
$I->fillField('Password', 'password_0');
|
||||
$I->click('login-button');
|
||||
|
||||
$I->see('Logout (erau)', 'form button[type=submit]');
|
||||
$I->dontSeeLink('Login');
|
||||
$I->dontSeeLink('Signup');
|
||||
}
|
||||
}
|
16
backend/tests/functional/_bootstrap.php
Normal file
16
backend/tests/functional/_bootstrap.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Here you can initialize variables via \Codeception\Util\Fixtures class
|
||||
* to store data in global array and use it in Cests.
|
||||
*
|
||||
* ```php
|
||||
* // Here _bootstrap.php
|
||||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
|
||||
* ```
|
||||
*
|
||||
* In Cests
|
||||
*
|
||||
* ```php
|
||||
* \Codeception\Util\Fixtures::get('user1');
|
||||
* ```
|
||||
*/
|
2
backend/tests/unit.suite.yml
Normal file
2
backend/tests/unit.suite.yml
Normal file
@ -0,0 +1,2 @@
|
||||
suite_namespace: backend\tests\unit
|
||||
actor: UnitTester
|
16
backend/tests/unit/_bootstrap.php
Normal file
16
backend/tests/unit/_bootstrap.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Here you can initialize variables via \Codeception\Util\Fixtures class
|
||||
* to store data in global array and use it in Tests.
|
||||
*
|
||||
* ```php
|
||||
* // Here _bootstrap.php
|
||||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
|
||||
* ```
|
||||
*
|
||||
* In Tests
|
||||
*
|
||||
* ```php
|
||||
* \Codeception\Util\Fixtures::get('user1');
|
||||
* ```
|
||||
*/
|
235
backend/views/layouts/content.php
Normal file
235
backend/views/layouts/content.php
Normal file
@ -0,0 +1,235 @@
|
||||
<?php
|
||||
use yii\widgets\Breadcrumbs;
|
||||
use dmstr\widgets\Alert;
|
||||
|
||||
?>
|
||||
<div class="content-wrapper">
|
||||
<section class="content-header">
|
||||
<?php if (isset($this->blocks['content-header'])) { ?>
|
||||
<h1><?= $this->blocks['content-header'] ?></h1>
|
||||
<?php } else { ?>
|
||||
<h1>
|
||||
<?php
|
||||
if ($this->title !== null) {
|
||||
echo \yii\helpers\Html::encode($this->title);
|
||||
} else {
|
||||
echo \yii\helpers\Inflector::camel2words(
|
||||
\yii\helpers\Inflector::id2camel($this->context->module->id)
|
||||
);
|
||||
echo ($this->context->module->id !== \Yii::$app->id) ? '<small>Module</small>' : '';
|
||||
} ?>
|
||||
</h1>
|
||||
<?php } ?>
|
||||
|
||||
<?=
|
||||
Breadcrumbs::widget(
|
||||
[
|
||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
|
||||
]
|
||||
) ?>
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
<?= Alert::widget() ?>
|
||||
<?= $content ?>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<footer class="main-footer">
|
||||
<div class="pull-right hidden-xs">
|
||||
<b>Version</b> 2.0
|
||||
</div>
|
||||
<strong>Copyright © 2014-2015 <a href="http://almsaeedstudio.com">Almsaeed Studio</a>.</strong> All rights
|
||||
reserved.
|
||||
</footer>
|
||||
|
||||
<!-- Control Sidebar -->
|
||||
<aside class="control-sidebar control-sidebar-dark">
|
||||
<!-- Create the tabs -->
|
||||
<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
|
||||
<li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
|
||||
<li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
|
||||
</ul>
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<!-- Home tab content -->
|
||||
<div class="tab-pane" id="control-sidebar-home-tab">
|
||||
<h3 class="control-sidebar-heading">Recent Activity</h3>
|
||||
<ul class='control-sidebar-menu'>
|
||||
<li>
|
||||
<a href='javascript::;'>
|
||||
<i class="menu-icon fa fa-birthday-cake bg-red"></i>
|
||||
|
||||
<div class="menu-info">
|
||||
<h4 class="control-sidebar-subheading">Langdon's Birthday</h4>
|
||||
|
||||
<p>Will be 23 on April 24th</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='javascript::;'>
|
||||
<i class="menu-icon fa fa-user bg-yellow"></i>
|
||||
|
||||
<div class="menu-info">
|
||||
<h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>
|
||||
|
||||
<p>New phone +1(800)555-1234</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='javascript::;'>
|
||||
<i class="menu-icon fa fa-envelope-o bg-light-blue"></i>
|
||||
|
||||
<div class="menu-info">
|
||||
<h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>
|
||||
|
||||
<p>nora@example.com</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='javascript::;'>
|
||||
<i class="menu-icon fa fa-file-code-o bg-green"></i>
|
||||
|
||||
<div class="menu-info">
|
||||
<h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>
|
||||
|
||||
<p>Execution time 5 seconds</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- /.control-sidebar-menu -->
|
||||
|
||||
<h3 class="control-sidebar-heading">Tasks Progress</h3>
|
||||
<ul class='control-sidebar-menu'>
|
||||
<li>
|
||||
<a href='javascript::;'>
|
||||
<h4 class="control-sidebar-subheading">
|
||||
Custom Template Design
|
||||
<span class="label label-danger pull-right">70%</span>
|
||||
</h4>
|
||||
|
||||
<div class="progress progress-xxs">
|
||||
<div class="progress-bar progress-bar-danger" style="width: 70%"></div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='javascript::;'>
|
||||
<h4 class="control-sidebar-subheading">
|
||||
Update Resume
|
||||
<span class="label label-success pull-right">95%</span>
|
||||
</h4>
|
||||
|
||||
<div class="progress progress-xxs">
|
||||
<div class="progress-bar progress-bar-success" style="width: 95%"></div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='javascript::;'>
|
||||
<h4 class="control-sidebar-subheading">
|
||||
Laravel Integration
|
||||
<span class="label label-waring pull-right">50%</span>
|
||||
</h4>
|
||||
|
||||
<div class="progress progress-xxs">
|
||||
<div class="progress-bar progress-bar-warning" style="width: 50%"></div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='javascript::;'>
|
||||
<h4 class="control-sidebar-subheading">
|
||||
Back End Framework
|
||||
<span class="label label-primary pull-right">68%</span>
|
||||
</h4>
|
||||
|
||||
<div class="progress progress-xxs">
|
||||
<div class="progress-bar progress-bar-primary" style="width: 68%"></div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- /.control-sidebar-menu -->
|
||||
|
||||
</div>
|
||||
<!-- /.tab-pane -->
|
||||
|
||||
<!-- Settings tab content -->
|
||||
<div class="tab-pane" id="control-sidebar-settings-tab">
|
||||
<form method="post">
|
||||
<h3 class="control-sidebar-heading">General Settings</h3>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-sidebar-subheading">
|
||||
Report panel usage
|
||||
<input type="checkbox" class="pull-right" checked/>
|
||||
</label>
|
||||
|
||||
<p>
|
||||
Some information about this general settings option
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.form-group -->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-sidebar-subheading">
|
||||
Allow mail redirect
|
||||
<input type="checkbox" class="pull-right" checked/>
|
||||
</label>
|
||||
|
||||
<p>
|
||||
Other sets of options are available
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.form-group -->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-sidebar-subheading">
|
||||
Expose author name in posts
|
||||
<input type="checkbox" class="pull-right" checked/>
|
||||
</label>
|
||||
|
||||
<p>
|
||||
Allow the user to show his name in blog posts
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.form-group -->
|
||||
|
||||
<h3 class="control-sidebar-heading">Chat Settings</h3>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-sidebar-subheading">
|
||||
Show me as online
|
||||
<input type="checkbox" class="pull-right" checked/>
|
||||
</label>
|
||||
</div>
|
||||
<!-- /.form-group -->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-sidebar-subheading">
|
||||
Turn off notifications
|
||||
<input type="checkbox" class="pull-right"/>
|
||||
</label>
|
||||
</div>
|
||||
<!-- /.form-group -->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-sidebar-subheading">
|
||||
Delete chat history
|
||||
<a href="javascript::;" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
|
||||
</label>
|
||||
</div>
|
||||
<!-- /.form-group -->
|
||||
</form>
|
||||
</div>
|
||||
<!-- /.tab-pane -->
|
||||
</div>
|
||||
</aside><!-- /.control-sidebar -->
|
||||
<!-- Add the sidebar's background. This div must be placed
|
||||
immediately after the control sidebar -->
|
||||
<div class='control-sidebar-bg'></div>
|
281
backend/views/layouts/header.php
Normal file
281
backend/views/layouts/header.php
Normal file
@ -0,0 +1,281 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $content string */
|
||||
?>
|
||||
|
||||
<header class="main-header">
|
||||
|
||||
<?= Html::a('<span class="logo-mini">APP</span><span class="logo-lg">' . Yii::$app->name . '</span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>
|
||||
|
||||
<nav class="navbar navbar-static-top" role="navigation">
|
||||
|
||||
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</a>
|
||||
|
||||
<div class="navbar-custom-menu">
|
||||
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
<!-- Messages: style can be found in dropdown.less-->
|
||||
<li class="dropdown messages-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-envelope-o"></i>
|
||||
<span class="label label-success">4</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="header">You have 4 messages</li>
|
||||
<li>
|
||||
<!-- inner menu: contains the actual data -->
|
||||
<ul class="menu">
|
||||
<li><!-- start message -->
|
||||
<a href="#">
|
||||
<div class="pull-left">
|
||||
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle"
|
||||
alt="User Image"/>
|
||||
</div>
|
||||
<h4>
|
||||
Support Team
|
||||
<small><i class="fa fa-clock-o"></i> 5 mins</small>
|
||||
</h4>
|
||||
<p>Why not buy a new awesome theme?</p>
|
||||
</a>
|
||||
</li>
|
||||
<!-- end message -->
|
||||
<li>
|
||||
<a href="#">
|
||||
<div class="pull-left">
|
||||
<img src="<?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle"
|
||||
alt="user image"/>
|
||||
</div>
|
||||
<h4>
|
||||
AdminLTE Design Team
|
||||
<small><i class="fa fa-clock-o"></i> 2 hours</small>
|
||||
</h4>
|
||||
<p>Why not buy a new awesome theme?</p>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<div class="pull-left">
|
||||
<img src="<?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle"
|
||||
alt="user image"/>
|
||||
</div>
|
||||
<h4>
|
||||
Developers
|
||||
<small><i class="fa fa-clock-o"></i> Today</small>
|
||||
</h4>
|
||||
<p>Why not buy a new awesome theme?</p>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<div class="pull-left">
|
||||
<img src="<?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle"
|
||||
alt="user image"/>
|
||||
</div>
|
||||
<h4>
|
||||
Sales Department
|
||||
<small><i class="fa fa-clock-o"></i> Yesterday</small>
|
||||
</h4>
|
||||
<p>Why not buy a new awesome theme?</p>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<div class="pull-left">
|
||||
<img src="<?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle"
|
||||
alt="user image"/>
|
||||
</div>
|
||||
<h4>
|
||||
Reviewers
|
||||
<small><i class="fa fa-clock-o"></i> 2 days</small>
|
||||
</h4>
|
||||
<p>Why not buy a new awesome theme?</p>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="footer"><a href="#">See All Messages</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown notifications-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-bell-o"></i>
|
||||
<span class="label label-warning">10</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="header">You have 10 notifications</li>
|
||||
<li>
|
||||
<!-- inner menu: contains the actual data -->
|
||||
<ul class="menu">
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-users text-aqua"></i> 5 new members joined today
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-warning text-yellow"></i> Very long description here that may
|
||||
not fit into the page and may cause design problems
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-users text-red"></i> 5 new members joined
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-shopping-cart text-green"></i> 25 sales made
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user text-red"></i> You changed your username
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="footer"><a href="#">View all</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<!-- Tasks: style can be found in dropdown.less -->
|
||||
<li class="dropdown tasks-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-flag-o"></i>
|
||||
<span class="label label-danger">9</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="header">You have 9 tasks</li>
|
||||
<li>
|
||||
<!-- inner menu: contains the actual data -->
|
||||
<ul class="menu">
|
||||
<li><!-- Task item -->
|
||||
<a href="#">
|
||||
<h3>
|
||||
Design some buttons
|
||||
<small class="pull-right">20%</small>
|
||||
</h3>
|
||||
<div class="progress xs">
|
||||
<div class="progress-bar progress-bar-aqua" style="width: 20%"
|
||||
role="progressbar" aria-valuenow="20" aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
<span class="sr-only">20% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<!-- end task item -->
|
||||
<li><!-- Task item -->
|
||||
<a href="#">
|
||||
<h3>
|
||||
Create a nice theme
|
||||
<small class="pull-right">40%</small>
|
||||
</h3>
|
||||
<div class="progress xs">
|
||||
<div class="progress-bar progress-bar-green" style="width: 40%"
|
||||
role="progressbar" aria-valuenow="20" aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
<span class="sr-only">40% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<!-- end task item -->
|
||||
<li><!-- Task item -->
|
||||
<a href="#">
|
||||
<h3>
|
||||
Some task I need to do
|
||||
<small class="pull-right">60%</small>
|
||||
</h3>
|
||||
<div class="progress xs">
|
||||
<div class="progress-bar progress-bar-red" style="width: 60%"
|
||||
role="progressbar" aria-valuenow="20" aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
<span class="sr-only">60% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<!-- end task item -->
|
||||
<li><!-- Task item -->
|
||||
<a href="#">
|
||||
<h3>
|
||||
Make beautiful transitions
|
||||
<small class="pull-right">80%</small>
|
||||
</h3>
|
||||
<div class="progress xs">
|
||||
<div class="progress-bar progress-bar-yellow" style="width: 80%"
|
||||
role="progressbar" aria-valuenow="20" aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
<span class="sr-only">80% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<!-- end task item -->
|
||||
</ul>
|
||||
</li>
|
||||
<li class="footer">
|
||||
<a href="#">View all tasks</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<!-- User Account: style can be found in dropdown.less -->
|
||||
|
||||
<li class="dropdown user user-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="user-image" alt="User Image"/>
|
||||
<span class="hidden-xs">Alexander Pierce</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- User image -->
|
||||
<li class="user-header">
|
||||
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle"
|
||||
alt="User Image"/>
|
||||
|
||||
<p>
|
||||
Alexander Pierce - Web Developer
|
||||
<small>Member since Nov. 2012</small>
|
||||
</p>
|
||||
</li>
|
||||
<!-- Menu Body -->
|
||||
<li class="user-body">
|
||||
<div class="col-xs-4 text-center">
|
||||
<a href="#">Followers</a>
|
||||
</div>
|
||||
<div class="col-xs-4 text-center">
|
||||
<a href="#">Sales</a>
|
||||
</div>
|
||||
<div class="col-xs-4 text-center">
|
||||
<a href="#">Friends</a>
|
||||
</div>
|
||||
</li>
|
||||
<!-- Menu Footer-->
|
||||
<li class="user-footer">
|
||||
<div class="pull-left">
|
||||
<a href="#" class="btn btn-default btn-flat">Profile</a>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<?= Html::a(
|
||||
'Sign out',
|
||||
['/site/logout'],
|
||||
['data-method' => 'post', 'class' => 'btn btn-default btn-flat']
|
||||
) ?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!-- User Account: style can be found in dropdown.less -->
|
||||
<li>
|
||||
<a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
48
backend/views/layouts/left.php
Normal file
48
backend/views/layouts/left.php
Normal file
@ -0,0 +1,48 @@
|
||||
<aside class="main-sidebar">
|
||||
<section class="sidebar">
|
||||
|
||||
<?= dmstr\widgets\Menu::widget(
|
||||
[
|
||||
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
|
||||
'items' => [
|
||||
['label' => 'Статусы', 'icon' => 'anchor', 'url' => ['/status/status']],
|
||||
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/fields/additional-fields']],
|
||||
['label' => 'Профили', 'icon' => 'users', 'url' => ['/card/user-card']],
|
||||
['label' => 'Пректы', 'icon' => 'files-o', 'url' => ['/project/project']],
|
||||
|
||||
/*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],
|
||||
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']],
|
||||
['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
|
||||
[
|
||||
'label' => 'Some tools',
|
||||
'icon' => 'share',
|
||||
'url' => '#',
|
||||
'items' => [
|
||||
['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'],],
|
||||
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'],],
|
||||
[
|
||||
'label' => 'Level One',
|
||||
'icon' => 'circle-o',
|
||||
'url' => '#',
|
||||
'items' => [
|
||||
['label' => 'Level Two', 'icon' => 'circle-o', 'url' => '#',],
|
||||
[
|
||||
'label' => 'Level Two',
|
||||
'icon' => 'circle-o',
|
||||
'url' => '#',
|
||||
'items' => [
|
||||
['label' => 'Level Three', 'icon' => 'circle-o', 'url' => '#',],
|
||||
['label' => 'Level Three', 'icon' => 'circle-o', 'url' => '#',],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],*/
|
||||
],
|
||||
]
|
||||
) ?>
|
||||
|
||||
</section>
|
||||
|
||||
</aside>
|
29
backend/views/layouts/main-login.php
Normal file
29
backend/views/layouts/main-login.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
use backend\assets\AppAsset;
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $content string */
|
||||
|
||||
dmstr\web\AdminLteAsset::register($this);
|
||||
?>
|
||||
<?php $this->beginPage() ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= Yii::$app->language ?>">
|
||||
<head>
|
||||
<meta charset="<?= Yii::$app->charset ?>"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<?= Html::csrfMetaTags() ?>
|
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
<?php $this->head() ?>
|
||||
</head>
|
||||
<body class="login-page">
|
||||
|
||||
<?php $this->beginBody() ?>
|
||||
|
||||
<?= $content ?>
|
||||
|
||||
<?php $this->endBody() ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php $this->endPage() ?>
|
65
backend/views/layouts/main.php
Normal file
65
backend/views/layouts/main.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $content string */
|
||||
|
||||
|
||||
if (Yii::$app->controller->action->id === 'login') {
|
||||
/**
|
||||
* Do not use this code in your template. Remove it.
|
||||
* Instead, use the code $this->layout = '//main-login'; in your controller.
|
||||
*/
|
||||
echo $this->render(
|
||||
'main-login',
|
||||
['content' => $content]
|
||||
);
|
||||
} else {
|
||||
|
||||
if (class_exists('backend\assets\AppAsset')) {
|
||||
backend\assets\AppAsset::register($this);
|
||||
} else {
|
||||
app\assets\AppAsset::register($this);
|
||||
}
|
||||
|
||||
dmstr\web\AdminLteAsset::register($this);
|
||||
|
||||
$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist');
|
||||
?>
|
||||
<?php $this->beginPage() ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= Yii::$app->language ?>">
|
||||
<head>
|
||||
<meta charset="<?= Yii::$app->charset ?>"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<?= Html::csrfMetaTags() ?>
|
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
<?php $this->head() ?>
|
||||
</head>
|
||||
<body class="hold-transition skin-blue sidebar-mini">
|
||||
<?php $this->beginBody() ?>
|
||||
<div class="wrapper">
|
||||
|
||||
<?= $this->render(
|
||||
'header.php',
|
||||
['directoryAsset' => $directoryAsset]
|
||||
) ?>
|
||||
|
||||
<?= $this->render(
|
||||
'left.php',
|
||||
['directoryAsset' => $directoryAsset]
|
||||
)
|
||||
?>
|
||||
|
||||
<?= $this->render(
|
||||
'content.php',
|
||||
['content' => $content, 'directoryAsset' => $directoryAsset]
|
||||
) ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php $this->endBody() ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php $this->endPage() ?>
|
||||
<?php } ?>
|
44
backend/views/site/error.php
Normal file
44
backend/views/site/error.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $name string */
|
||||
/* @var $message string */
|
||||
/* @var $exception Exception */
|
||||
|
||||
$this->title = $name;
|
||||
?>
|
||||
<section class="content">
|
||||
|
||||
<div class="error-page">
|
||||
<h2 class="headline text-info"><i class="fa fa-warning text-yellow"></i></h2>
|
||||
|
||||
<div class="error-content">
|
||||
<h3><?= $name ?></h3>
|
||||
|
||||
<p>
|
||||
<?= nl2br(Html::encode($message)) ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The above error occurred while the Web server was processing your request.
|
||||
Please contact us if you think this is a server error. Thank you.
|
||||
Meanwhile, you may <a href='<?= Yii::$app->homeUrl ?>'>return to dashboard</a> or try using the search
|
||||
form.
|
||||
</p>
|
||||
|
||||
<form class='search-form'>
|
||||
<div class='input-group'>
|
||||
<input type="text" name="search" class='form-control' placeholder="Search"/>
|
||||
|
||||
<div class="input-group-btn">
|
||||
<button type="submit" name="submit" class="btn btn-primary"><i class="fa fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
53
backend/views/site/index.php
Normal file
53
backend/views/site/index.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
|
||||
$this->title = 'My Yii Application';
|
||||
?>
|
||||
<div class="site-index">
|
||||
|
||||
<div class="jumbotron">
|
||||
<h1>Congratulations!</h1>
|
||||
|
||||
<p class="lead">You have successfully created your Yii-powered application.</p>
|
||||
|
||||
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
|
||||
</div>
|
||||
|
||||
<div class="body-content">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<h2>Heading</h2>
|
||||
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
||||
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
||||
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
||||
fugiat nulla pariatur.</p>
|
||||
|
||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation »</a></p>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<h2>Heading</h2>
|
||||
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
||||
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
||||
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
||||
fugiat nulla pariatur.</p>
|
||||
|
||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum »</a></p>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<h2>Heading</h2>
|
||||
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
||||
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
||||
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
||||
fugiat nulla pariatur.</p>
|
||||
|
||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
70
backend/views/site/login.php
Normal file
70
backend/views/site/login.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
use yii\bootstrap\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $form yii\bootstrap\ActiveForm */
|
||||
/* @var $model \common\models\LoginForm */
|
||||
|
||||
$this->title = 'Sign In';
|
||||
|
||||
$fieldOptions1 = [
|
||||
'options' => ['class' => 'form-group has-feedback'],
|
||||
'inputTemplate' => "{input}<span class='glyphicon glyphicon-envelope form-control-feedback'></span>"
|
||||
];
|
||||
|
||||
$fieldOptions2 = [
|
||||
'options' => ['class' => 'form-group has-feedback'],
|
||||
'inputTemplate' => "{input}<span class='glyphicon glyphicon-lock form-control-feedback'></span>"
|
||||
];
|
||||
?>
|
||||
|
||||
<div class="login-box">
|
||||
<div class="login-logo">
|
||||
<a href="#"><b>Admin</b>LTE</a>
|
||||
</div>
|
||||
<!-- /.login-logo -->
|
||||
<div class="login-box-body">
|
||||
<p class="login-box-msg">Sign in to start your session</p>
|
||||
|
||||
<?php $form = ActiveForm::begin(['id' => 'login-form', 'enableClientValidation' => false]); ?>
|
||||
|
||||
<?= $form
|
||||
->field($model, 'username', $fieldOptions1)
|
||||
->label(false)
|
||||
->textInput(['placeholder' => $model->getAttributeLabel('username')]) ?>
|
||||
|
||||
<?= $form
|
||||
->field($model, 'password', $fieldOptions2)
|
||||
->label(false)
|
||||
->passwordInput(['placeholder' => $model->getAttributeLabel('password')]) ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-8">
|
||||
<?= $form->field($model, 'rememberMe')->checkbox() ?>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-xs-4">
|
||||
<?= Html::submitButton('Sign in', ['class' => 'btn btn-primary btn-block btn-flat', 'name' => 'login-button']) ?>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
<div class="social-auth-links text-center">
|
||||
<p>- OR -</p>
|
||||
<a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign in
|
||||
using Facebook</a>
|
||||
<a href="#" class="btn btn-block btn-social btn-google-plus btn-flat"><i class="fa fa-google-plus"></i> Sign
|
||||
in using Google+</a>
|
||||
</div>
|
||||
<!-- /.social-auth-links -->
|
||||
|
||||
<a href="#">I forgot my password</a><br>
|
||||
<a href="register.html" class="text-center">Register a new membership</a>
|
||||
|
||||
</div>
|
||||
<!-- /.login-box-body -->
|
||||
</div><!-- /.login-box -->
|
3
backend/web/.gitignore
vendored
Normal file
3
backend/web/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/index.php
|
||||
/index-test.php
|
||||
/robots.txt
|
19
backend/web/.htaccess
Normal file
19
backend/web/.htaccess
Normal file
@ -0,0 +1,19 @@
|
||||
# <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
|
||||
#RewriteCond %{REQUEST_FILENAME} !-f
|
||||
#RewriteCond %{REQUEST_FILENAME} !-d
|
||||
# <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> index.php
|
||||
#RewriteRule . index.php
|
||||
|
||||
Options +SymLinksIfOwnerMatch
|
||||
IndexIgnore /
|
||||
|
||||
RewriteEngine on
|
||||
#RewriteBase /
|
||||
|
||||
# if a directory or a file exists, use it directly
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
# otherwise forward it to index.php
|
||||
RewriteRule . index.php
|
||||
|
2
backend/web/assets/.gitignore
vendored
Normal file
2
backend/web/assets/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
21
backend/web/css/site.css
Normal file
21
backend/web/css/site.css
Normal file
@ -0,0 +1,21 @@
|
||||
.media__upload_img{
|
||||
margin-bottom: 10px;
|
||||
float: left;
|
||||
}
|
||||
.input-group {
|
||||
position: relative;
|
||||
display: table;
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
}
|
||||
|
||||
.itemImg, .itemImgs{
|
||||
float: left!important;
|
||||
display: inline-block;
|
||||
width: 30%!important;
|
||||
}
|
||||
|
||||
.media__upload_img img{
|
||||
margin: 3px;
|
||||
object-fit: cover;
|
||||
}
|
BIN
backend/web/favicon.ico
Normal file
BIN
backend/web/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 318 B |
9
codeception.yml
Normal file
9
codeception.yml
Normal file
@ -0,0 +1,9 @@
|
||||
# global codeception file to run tests from all apps
|
||||
include:
|
||||
- common
|
||||
- frontend
|
||||
- backend
|
||||
paths:
|
||||
log: console/runtime/logs
|
||||
settings:
|
||||
colors: true
|
20
common/classes/Debug.php
Normal file
20
common/classes/Debug.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace common\classes;
|
||||
|
||||
class Debug
|
||||
{
|
||||
public static function prn($content)
|
||||
{
|
||||
echo '<pre style="background: lightgray; border: 1px solid black; padding: 2px">';
|
||||
print_r($content);
|
||||
echo '</pre>';
|
||||
}
|
||||
public static function dd($content)
|
||||
{
|
||||
echo '<pre style="background: lightgray; border: 1px solid black; padding: 2px">';
|
||||
print_r($content);
|
||||
echo '</pre>';
|
||||
die();
|
||||
}
|
||||
}
|
15
common/codeception.yml
Normal file
15
common/codeception.yml
Normal file
@ -0,0 +1,15 @@
|
||||
namespace: common\tests
|
||||
actor_suffix: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
output: tests/_output
|
||||
data: tests/_data
|
||||
support: tests/_support
|
||||
settings:
|
||||
bootstrap: _bootstrap.php
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
modules:
|
||||
config:
|
||||
Yii2:
|
||||
configFile: 'config/test-local.php'
|
3
common/config/.gitignore
vendored
Normal file
3
common/config/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
main-local.php
|
||||
params-local.php
|
||||
test-local.php
|
5
common/config/bootstrap.php
Normal file
5
common/config/bootstrap.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
Yii::setAlias('@common', dirname(__DIR__));
|
||||
Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
|
||||
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
|
||||
Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
|
37
common/config/main.php
Normal file
37
common/config/main.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
return [
|
||||
'aliases' => [
|
||||
'@bower' => '@vendor/bower-asset',
|
||||
'@npm' => '@vendor/npm-asset',
|
||||
],
|
||||
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
|
||||
'components' => [
|
||||
'cache' => [
|
||||
'class' => 'yii\caching\FileCache',
|
||||
],
|
||||
],
|
||||
'controllerMap' => [
|
||||
'elfinder' => [
|
||||
'class' => 'mihaildev\elfinder\Controller',
|
||||
'access' => ['@', '?'],
|
||||
'disabledCommands' => ['netmount'],
|
||||
'roots' => [
|
||||
[
|
||||
'baseUrl' => '',
|
||||
'basePath' => '@frontend/web',
|
||||
'path' => 'media/upload',
|
||||
'name' => 'Изображения',
|
||||
],
|
||||
],
|
||||
'watermark' => [
|
||||
'source' => __DIR__ . '/logo.png', // Path to Water mark image
|
||||
'marginRight' => 5, // Margin right pixel
|
||||
'marginBottom' => 5, // Margin bottom pixel
|
||||
'quality' => 95, // JPEG image save quality
|
||||
'transparency' => 70, // Water mark image transparency ( other than PNG )
|
||||
'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field )
|
||||
'targetMinPixel' => 200 // Target image minimum pixel size
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
6
common/config/params.php
Normal file
6
common/config/params.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
'supportEmail' => 'support@example.com',
|
||||
'user.passwordResetTokenExpire' => 3600,
|
||||
];
|
14
common/config/test.php
Normal file
14
common/config/test.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => 'app-common-tests',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'components' => [
|
||||
'user' => [
|
||||
'class' => 'yii\web\User',
|
||||
'identityClass' => 'common\models\User',
|
||||
],
|
||||
'request' => [
|
||||
'cookieValidationKey' => 'test',
|
||||
],
|
||||
],
|
||||
];
|
9
common/fixtures/UserFixture.php
Normal file
9
common/fixtures/UserFixture.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace common\fixtures;
|
||||
|
||||
use yii\test\ActiveFixture;
|
||||
|
||||
class UserFixture extends ActiveFixture
|
||||
{
|
||||
public $modelClass = 'common\models\User';
|
||||
}
|
22
common/mail/layouts/html.php
Normal file
22
common/mail/layouts/html.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this \yii\web\View view component instance */
|
||||
/* @var $message \yii\mail\MessageInterface the message being composed */
|
||||
/* @var $content string main view render result */
|
||||
?>
|
||||
<?php $this->beginPage() ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
|
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
<?php $this->head() ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php $this->beginBody() ?>
|
||||
<?= $content ?>
|
||||
<?php $this->endBody() ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php $this->endPage() ?>
|
14
common/mail/layouts/text.php
Normal file
14
common/mail/layouts/text.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/** @var \yii\web\View $this view component instance */
|
||||
/** @var \yii\mail\MessageInterface $message the message being composed */
|
||||
/** @var string $content main view render result */
|
||||
?>
|
||||
|
||||
<?php $this->beginPage() ?>
|
||||
<?php $this->beginBody() ?>
|
||||
<?= $content ?>
|
||||
<?php $this->endBody() ?>
|
||||
<?php $this->endPage() ?>
|
15
common/mail/passwordResetToken-html.php
Normal file
15
common/mail/passwordResetToken-html.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $user common\models\User */
|
||||
|
||||
$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
|
||||
?>
|
||||
<div class="password-reset">
|
||||
<p>Hello <?= Html::encode($user->username) ?>,</p>
|
||||
|
||||
<p>Follow the link below to reset your password:</p>
|
||||
|
||||
<p><?= Html::a(Html::encode($resetLink), $resetLink) ?></p>
|
||||
</div>
|
12
common/mail/passwordResetToken-text.php
Normal file
12
common/mail/passwordResetToken-text.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $user common\models\User */
|
||||
|
||||
$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
|
||||
?>
|
||||
Hello <?= $user->username ?>,
|
||||
|
||||
Follow the link below to reset your password:
|
||||
|
||||
<?= $resetLink ?>
|
66
common/models/AdditionalFields.php
Normal file
66
common/models/AdditionalFields.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "additional_fields".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
*
|
||||
* @property FieldsValue[] $fieldsValues
|
||||
* @property UseField[] $useFields
|
||||
*/
|
||||
class AdditionalFields extends \yii\db\ActiveRecord
|
||||
{
|
||||
public $use = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'additional_fields';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'use'], 'required'],
|
||||
[['name'], 'string', 'max' => 100],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Название',
|
||||
'use' => 'Применение',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
return $this->hasMany(FieldsValue::className(), ['field_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getUseFields()
|
||||
{
|
||||
return $this->hasMany(UseField::className(), ['field_id' => 'id']);
|
||||
}
|
||||
}
|
82
common/models/FieldsValue.php
Normal file
82
common/models/FieldsValue.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "fields_value".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $card_id
|
||||
* @property int $project_id
|
||||
* @property int $field_id
|
||||
* @property string $value
|
||||
* @property int $order
|
||||
*
|
||||
* @property AdditionalFields $field
|
||||
* @property UserCard $card
|
||||
*/
|
||||
class FieldsValue extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'fields_value';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['field_id', 'value'], 'required'],
|
||||
[['card_id', 'field_id', 'order', 'project_id'], 'integer'],
|
||||
[['value'], 'string', 'max' => 255],
|
||||
[['field_id'], 'exist', 'skipOnError' => true, 'targetClass' => AdditionalFields::class, 'targetAttribute' => ['field_id' => 'id']],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::class, 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::class, 'targetAttribute' => ['card_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'card_id' => 'Card ID',
|
||||
'field_id' => 'Field ID',
|
||||
'value' => 'Value',
|
||||
'project_id' => 'Project ID',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getField()
|
||||
{
|
||||
return $this->hasOne(AdditionalFields::class, ['id' => 'field_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getProject()
|
||||
{
|
||||
return $this->hasOne(Project::class, ['id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->hasOne(UserCard::class, ['id' => 'card_id']);
|
||||
}
|
||||
}
|
78
common/models/LoginForm.php
Normal file
78
common/models/LoginForm.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
/**
|
||||
* Login form
|
||||
*/
|
||||
class LoginForm extends Model
|
||||
{
|
||||
public $username;
|
||||
public $password;
|
||||
public $rememberMe = true;
|
||||
|
||||
private $_user;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// username and password are both required
|
||||
[['username', 'password'], 'required'],
|
||||
// rememberMe must be a boolean value
|
||||
['rememberMe', 'boolean'],
|
||||
// password is validated by validatePassword()
|
||||
['password', 'validatePassword'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the password.
|
||||
* This method serves as the inline validation for password.
|
||||
*
|
||||
* @param string $attribute the attribute currently being validated
|
||||
* @param array $params the additional name-value pairs given in the rule
|
||||
*/
|
||||
public function validatePassword($attribute, $params)
|
||||
{
|
||||
if (!$this->hasErrors()) {
|
||||
$user = $this->getUser();
|
||||
if (!$user || !$user->validatePassword($this->password)) {
|
||||
$this->addError($attribute, 'Incorrect username or password.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in a user using the provided username and password.
|
||||
*
|
||||
* @return bool whether the user is logged in successfully
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if ($this->validate()) {
|
||||
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds user by [[username]]
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
protected function getUser()
|
||||
{
|
||||
if ($this->_user === null) {
|
||||
$this->_user = User::findByUsername($this->username);
|
||||
}
|
||||
|
||||
return $this->_user;
|
||||
}
|
||||
}
|
66
common/models/Project.php
Normal file
66
common/models/Project.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
|
||||
/**
|
||||
* This is the model class for table "project".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class Project extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'project';
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'createdAtAttribute' => 'created_at',
|
||||
'updatedAtAttribute' => 'updated_at',
|
||||
'value' => new Expression('NOW()'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['description'], 'string'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['name'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Название',
|
||||
'description' => 'Описание',
|
||||
'created_at' => 'Дата создания',
|
||||
'updated_at' => 'Дата редактирования',
|
||||
];
|
||||
}
|
||||
}
|
67
common/models/ProjectUser.php
Normal file
67
common/models/ProjectUser.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "project_user".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $card_id
|
||||
* @property int $project_id
|
||||
*
|
||||
* @property Project $project
|
||||
* @property UserCard $card
|
||||
*/
|
||||
class ProjectUser extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'project_user';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['card_id', 'project_id'], 'required'],
|
||||
[['card_id', 'project_id'], 'integer'],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['card_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'card_id' => 'Card ID',
|
||||
'project_id' => 'Project ID',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getProject()
|
||||
{
|
||||
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'card_id']);
|
||||
}
|
||||
}
|
66
common/models/Status.php
Normal file
66
common/models/Status.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "status".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
*
|
||||
* @property UseStatus[] $useStatuses
|
||||
* @property UserCard[] $userCards
|
||||
*/
|
||||
class Status extends \yii\db\ActiveRecord
|
||||
{
|
||||
public $use = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'status';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'use'], 'required'],
|
||||
[['name'], 'string', 'max' => 100],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Название',
|
||||
'use' => 'Применение',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getUseStatuses()
|
||||
{
|
||||
return $this->hasMany(UseStatus::class, ['status_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getUserCards()
|
||||
{
|
||||
return $this->hasMany(UserCard::class, ['status' => 'id']);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user