first commit

This commit is contained in:
king199025
2018-10-11 11:15:09 +03:00
commit 9e8e98c379
230 changed files with 12117 additions and 0 deletions

View 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
}
}

View 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.');
}
}

View 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
}
}

View 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;
}
}

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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
}
}

View File

@@ -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.');
}
}

View 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
}
}

View 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;
}
}

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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
}
}

View 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.');
}
}

View 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
}
}

View 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;
}
}

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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
}
}

View 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.');
}
}

View 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
}
}

View 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;
}
}

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>