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