Merge pull request #82 from apuc/add_document

Add document
This commit is contained in:
kavalar 2022-01-07 17:49:30 +03:00 committed by GitHub
commit 464dda1e39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
76 changed files with 15303 additions and 52 deletions

View File

@ -71,6 +71,9 @@ return [
'task' => [
'class' => 'backend\modules\task\Task',
],
'document' => [
'class' => 'backend\modules\document\Document',
],
],
'components' => [
'request' => [

View File

@ -0,0 +1,24 @@
<?php
namespace backend\modules\document;
/**
* document module definition class
*/
class Document extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'backend\modules\document\controllers';
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}

View File

@ -0,0 +1,141 @@
<?php
namespace backend\modules\document\controllers;
use Yii;
use backend\modules\document\models\Document;
use backend\modules\document\models\DocumentSearch;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* DocumentController implements the CRUD actions for Document model.
*/
class DocumentController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Document models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new DocumentSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Document model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
$model = $this->findModel($id);
$documentFieldValuesDataProvider = new ActiveDataProvider([
'query' => $model->getDocumentFieldValues(),//->with('questionType'),
'pagination' => [
'pageSize' => 20,
],
]);
return $this->render('view', [
'model' => $model,
'documentFieldValuesDataProvider' => $documentFieldValuesDataProvider
]);
}
/**
* Creates a new Document model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Document();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect([
'document-field-value/create-multiple',
'document_id' => $model->id,
'template_id' => $model->template_id
]);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Document 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 Document 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 Document model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Document the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Document::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -0,0 +1,127 @@
<?php
namespace backend\modules\document\controllers;
use Yii;
use backend\modules\document\models\DocumentField;
use backend\modules\document\models\DocumentFieldSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* DocumentFieldController implements the CRUD actions for DocumentField model.
*/
class DocumentFieldController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all DocumentField models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new DocumentFieldSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single DocumentField 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 DocumentField model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new DocumentField();
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 DocumentField 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 DocumentField 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 DocumentField model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return DocumentField the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = DocumentField::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -0,0 +1,186 @@
<?php
namespace backend\modules\document\controllers;
use backend\modules\document\models\DocumentField;
use Yii;
use backend\modules\document\models\DocumentFieldValue;
use backend\modules\document\models\DocumentFieldValueSearch;
use yii\base\Model;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* DocumentFieldValueController implements the CRUD actions for DocumentFieldValue model.
*/
class DocumentFieldValueController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all DocumentFieldValue models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new DocumentFieldValueSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single DocumentFieldValue 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 DocumentFieldValue model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($document_id)
{
$model = new DocumentFieldValue();
$model->document_id = $document_id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
if ($document_id !== null)
{
return $this->redirect(['document/view', 'id' => $document_id]);
}
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Creates a new DocumentFieldValue model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreateMultiple()
{
$document_id = Yii::$app->request->get('document_id');
$template_id = Yii::$app->request->get('template_id');
$fieldsIdTitleList = DocumentField::getIdFieldsTitleList($template_id);
$documentFieldValues = [];
if (empty($fieldsIdTitleList)) {
$documentFieldValues = [new DocumentFieldValue()];
}
else {
foreach ($fieldsIdTitleList as $fieldsIdTitle){
$tmpDocField = new DocumentFieldValue();
$tmpDocField->document_id = $document_id;
$tmpDocField->field_id = $fieldsIdTitle['id'];
$documentFieldValues[] = $tmpDocField;
}
if (Model::loadMultiple($documentFieldValues, Yii::$app->request->post()) && Model::validateMultiple($documentFieldValues)) {
foreach ($documentFieldValues as $documentFieldValue) {
$documentFieldValue->save(false);
}
return $this->redirect([
'document/view',
'id' => $document_id,
]);
}
}
return $this->render('_form_multiple', [
'documentFieldValues' => $documentFieldValues,
]);
}
/**
* Updates an existing DocumentFieldValue 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, $document_id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
if ($document_id !== null)
{
return $this->redirect(['document/view', 'id' => $document_id]);
}
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing DocumentFieldValue 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, $document_id)
{
$this->findModel($id)->delete();
if ($document_id !== null)
{
return $this->redirect(['document/view', 'id' => $document_id]);
}
return $this->redirect(['index']);
}
/**
* Finds the DocumentFieldValue model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return DocumentFieldValue the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = DocumentFieldValue::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -0,0 +1,180 @@
<?php
namespace backend\modules\document\controllers;
use backend\modules\document\models\TemplateDocumentField;
use Yii;
use backend\modules\document\models\Template;
use backend\modules\document\models\TemplateSearch;
use yii\base\Exception;
use yii\data\ActiveDataProvider;
use yii\helpers\FileHelper;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\Response;
use yii\web\UploadedFile;
/**
* TemplateController implements the CRUD actions for Template model.
*/
class TemplateController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Template models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TemplateSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Template model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
$model = $this->findModel($id);
$templateDocumentField = new TemplateDocumentField();
$templateFieldDataProvider = new ActiveDataProvider([
'query' => $model->getTemplateDocumentFields(),
'pagination' => [
'pageSize' => 20,
],
]);
return $this->render('view', [
'model' => $model,
'templateFieldDataProvider' => $templateFieldDataProvider,
]);
}
/**
* Creates a new Template model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return string|Response
* @throws Exception
*/
public function actionCreate()
{
$model = new Template();
if ($model->load(Yii::$app->request->post())) {
$model->template = UploadedFile::getInstance($model, 'template');
if (!empty($model->template)) {
$pathToTemplates = Yii::getAlias('@templates');
$model->template_file_name = date('mdyHis') . '_' . $model->template->name;
if ($model->save()) {
if (FileHelper::createDirectory($pathToTemplates, $mode = 0775, $recursive = true)) {
$model->template->saveAs($pathToTemplates . '/' . $model->template_file_name);
}
return $this->redirect(['template-document-field/create', 'template_id' => $model->id]);
}
return $this->render('create', ['model' => $model]);
}
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Template 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);
// $pathToFile = Yii::getAlias('@templates') . '/' . $model->template_file_name;
// if ($model->load(Yii::$app->request->post())) {
// $template = UploadedFile::getInstance($model, 'template');
//
// if (!empty($template)) {
// $path = Yii::getAlias('@frontend') . '/web/upload/documents/templates';
//
// $model->template = $template;
// $model->template_file_name = $model->template->name;
// $model->template_path = $path . '/' . $model->template->name;
//
// if (!$model->template->saveAs($path . '/' . $model->template->name)) {
// return $this->render('update', [
// 'model' => $model,
// ]);
// }
// }
// if ($model->save()) {
// return $this->redirect(['view', 'id' => $model->id]);
// }
// }
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
// $model->template = UploadedFile::getInstance($model, $pathToFile); // file($pathToFile);
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Template 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 Template model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Template the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Template::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -0,0 +1,153 @@
<?php
namespace backend\modules\document\controllers;
use Yii;
use backend\modules\document\models\TemplateDocumentField;
use backend\modules\document\models\TemplateDocumentFieldSearch;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* TemplateDocumentFieldController implements the CRUD actions for TemplateDocumentField model.
*/
class TemplateDocumentFieldController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all TemplateDocumentField models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TemplateDocumentFieldSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single TemplateDocumentField 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 TemplateDocumentField model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($template_id = null)
{
$post = \Yii::$app->request->post('TemplateDocumentField');
if (!empty($post)) {
$field_id_arr = ArrayHelper::getValue($post,'field_id');
foreach ($field_id_arr as $field_id) {
$emtModel = new TemplateDocumentField();
$emtModel->template_id = $post['template_id'];
$emtModel->field_id = $field_id;
if (!$emtModel->save()) {
return $this->render('create', [
'model' => $emtModel,
]);
}
}
if ($template_id !== null)
{
return $this->redirect(['template/view', 'id' => $template_id]);
}
return $this->redirect(['index']);
}
$model = new TemplateDocumentField();
$model->template_id = $template_id;
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing TemplateDocumentField 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 TemplateDocumentField 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(int $id, $template_id = null)
{
$this->findModel($id)->delete();
if ($template_id !== null)
{
return $this->redirect(['template/view', 'id' => $template_id]);
}
return $this->redirect(['index']);
}
/**
* Finds the TemplateDocumentField model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return TemplateDocumentField the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = TemplateDocumentField::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace backend\modules\document\models;
use Yii;
class Document extends \common\models\Document
{
}

View File

@ -0,0 +1,11 @@
<?php
namespace backend\modules\document\models;
use Yii;
class DocumentField extends \common\models\DocumentField
{
}

View File

@ -0,0 +1,68 @@
<?php
namespace backend\modules\document\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\document\models\DocumentField;
/**
* DocumentFieldSearch represents the model behind the search form of `backend\modules\document\models\DocumentField`.
*/
class DocumentFieldSearch extends DocumentField
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id'], 'integer'],
[['title'], '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 = DocumentField::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', 'title', $this->title]);
return $dataProvider;
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace backend\modules\document\models;
use Yii;
class DocumentFieldValue extends \common\models\DocumentFieldValue
{
}

View File

@ -0,0 +1,70 @@
<?php
namespace backend\modules\document\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\document\models\DocumentFieldValue;
/**
* DocumentFieldValueSearch represents the model behind the search form of `backend\modules\document\models\DocumentFieldValue`.
*/
class DocumentFieldValueSearch extends DocumentFieldValue
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'field_id', 'document_id'], 'integer'],
[['value'], '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 = DocumentFieldValue::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,
'field_id' => $this->field_id,
'document_id' => $this->document_id,
]);
$query->andFilterWhere(['like', 'value', $this->value]);
return $dataProvider;
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace backend\modules\document\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\document\models\Document;
/**
* DocumentSearch represents the model behind the search form of `backend\modules\document\models\Document`.
*/
class DocumentSearch extends Document
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'template_id', 'manager_id'], 'integer'],
[['title', '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 = Document::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,
'template_id' => $this->template_id,
'manager_id' => $this->manager_id,
]);
$query->andFilterWhere(['like', 'title', $this->title]);
return $dataProvider;
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace backend\modules\document\models;
class Template extends \common\models\Template
{
}

View File

@ -0,0 +1,11 @@
<?php
namespace backend\modules\document\models;
use Yii;
class TemplateDocumentField extends \common\models\TemplateDocumentField
{
}

View File

@ -0,0 +1,67 @@
<?php
namespace backend\modules\document\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\document\models\TemplateDocumentField;
/**
* TemplateDocumentFieldSearch represents the model behind the search form of `backend\modules\document\models\TemplateDocumentField`.
*/
class TemplateDocumentFieldSearch extends TemplateDocumentField
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'template_id', 'field_id'], 'integer'],
];
}
/**
* {@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 = TemplateDocumentField::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,
'template_id' => $this->template_id,
'field_id' => $this->field_id,
]);
return $dataProvider;
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace backend\modules\document\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\document\models\Template;
/**
* TemplateSearch represents the model behind the search form of `backend\modules\document\models\Template`.
*/
class TemplateSearch extends Template
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id'], 'integer'],
[['title', 'created_at', 'updated_at', 'template_file_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 = Template::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', 'title', $this->title])
->andFilterWhere(['like', 'template_file_name', $this->template_file_name]);
return $dataProvider;
}
}

View File

@ -0,0 +1,46 @@
<?php
use backend\modules\document\models\Document;
use common\models\DocumentField;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValue */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="document-field-value-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'document_id')->widget(Select2::className(),
[
'data' => Document::find()->select(['title', 'id'])
->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите документ','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]) ?>
<?= $form->field($model, 'field_id')->widget(Select2::className(),
[
'data' => DocumentField::find()->select(['title', 'id'])
->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите поле','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]) ?>
<?= $form->field($model, 'value')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,38 @@
<?php
use backend\modules\document\models\Document;
use common\models\DocumentField;
use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $documentFieldValues backend\modules\document\models\DocumentFieldValue[] */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="document-field-value-form">
<h2>
Заполнение полей документа: <?php echo(ArrayHelper::getValue($documentFieldValues[0], 'document.title')); ?>
</h2>
<?php $form = ActiveForm::begin(); ?>
<?php foreach ($documentFieldValues as $index => $documentFieldValue) { ?>
<?= $form->field($documentFieldValue, "[$index]value")
->textInput(['maxlength' => true])
->label(ArrayHelper::getValue($documentFieldValue,'field.title')
) ?>
<?php } ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValueSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="document-field-value-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'field_id') ?>
<?= $form->field($model, 'document_id') ?>
<?= $form->field($model, 'value') ?>
<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,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValue */
$this->title = 'Заполнить значение поля документа';
$this->params['breadcrumbs'][] = ['label' => 'Document Field Values', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-field-value-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,43 @@
<?php
use backend\modules\document\models\Document;
use common\models\DocumentField;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\document\models\DocumentFieldValueSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Значение полей документа';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-field-value-index">
<p>
<?= Html::a('Установить значение значение ', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'field_id',
'filter' => DocumentField::find()->select(['title', 'id'])->indexBy('id')->column(),
'value' => 'field.title'
],
[
'attribute' => 'document_id',
'filter' => Document::find()->select(['title', 'id'])->indexBy('id')->column(),
'value' => 'document.title'
],
'attribute' => 'value',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,20 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValue */
$this->title = 'Изменение значения поля документа';
$this->params['breadcrumbs'][] = ['label' => 'Document Field Values', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="document-field-value-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValue */
$this->title = $model->value;
$this->params['breadcrumbs'][] = ['label' => 'Document Field Values', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="document-field-value-view">
<p>
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= 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',
[
'attribute' => 'field_id',
'value' => ArrayHelper::getValue($model, 'field.title') // AnswerHelper::answerFlagLabel($model->answer_flag),
],
[
'attribute' => 'document_id',
'value' => ArrayHelper::getValue($model, 'document.title') // AnswerHelper::answerFlagLabel($model->answer_flag),
],
'value',
],
]) ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentField */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="document-field-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<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\document\models\DocumentFieldSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="document-field-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'title') ?>
<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,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentField */
$this->title = 'Создание поля документа';
$this->params['breadcrumbs'][] = ['label' => 'Document Fields', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-field-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,30 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\document\models\DocumentFieldSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Поля документов';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-field-index">
<p>
<?= Html::a('Создать поле документа', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'title',
['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\document\models\DocumentField */
$this->title = 'Изменение поля документа. Поле: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Document Fields', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="document-field-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\document\models\DocumentField */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Document Fields', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="document-field-view">
<p>
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= 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',
'title',
],
]) ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use backend\modules\document\models\Template;
use backend\modules\employee\models\Manager;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="document-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'manager_id')->widget(Select2::className(),
[
'data' => Manager::find()->select(['user_card.fio', 'manager.id'])
->joinWith('userCard')
->indexBy('manager.id')->column(),
'options' => ['placeholder' => 'Выберите менеджера','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]) ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'template_id')->widget(Select2::className(),
[
'data' => Template::find()->select(['title', 'id'])
->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите шаблон','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="document-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'title') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'updated_at') ?>
<?= $form->field($model, 'template_id') ?>
<?php // echo $form->field($model, 'manager_id') ?>
<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,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
$this->title = 'Создать документ';
$this->params['breadcrumbs'][] = ['label' => 'Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,88 @@
<?php
use backend\modules\document\models\Document;
use backend\modules\document\models\Template;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\document\models\DocumentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Документы';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-index">
<p>
<?= Html::a('Создать документ', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'title',
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'title',
'data' => Document::find()
->select(['title', 'id'])->indexBy('id')->column(),
'pluginOptions' => [
'allowClear' => true,
'width' => '150px',
],
'options' => [
'class' => 'form-control',
'placeholder' => 'Выберите значение'
],
]),
'value' => 'title',
],
[
'attribute' => 'template_id',
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'template_id',
'data' => Template::find()->select(['title', 'id'])->indexBy('id')->column(),
'pluginOptions' => [
'allowClear' => true,
'width' => '150px',
],
'options' => [
'class' => 'form-control',
'placeholder' => 'Выберите значение'
],
]),
'value' => 'template.title'
],
[
'attribute' => 'manager_id',
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'manager_id',
'data' => Document::find()
->joinWith(['manager', 'manager.userCard'])
->select(['user_card.fio', 'manager.id'])->indexBy('id')->column(),
'pluginOptions' => [
'allowClear' => true,
'width' => '150px',
],
'options' => [
'class' => 'form-control',
'placeholder' => 'Выберите значение'
],
]),
'value' => 'manager.userCard.fio',
],
'created_at',
'updated_at',
['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\document\models\Document */
$this->title = 'Изменить Документ: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="document-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,94 @@
<?php
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
/* @var $documentFieldValuesDataProvider yii\data\ActiveDataProvider */
$this->title = 'Документ: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="document-view">
<p>
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= 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',
'title',
'created_at',
'updated_at',
'template_id',
'manager_id',
],
]) ?>
<div>
<h2>
<?= 'Поля документа:'?>
</h2>
</div>
<?= GridView::widget([
'dataProvider' => $documentFieldValuesDataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'field_id',
'value' => 'field.title'
],
'attribute' => 'value',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'controller' => 'document-field-value',
'buttons' => [
'update' => function ($url,$model) {
return Html::a(
'<span class="glyphicon glyphicon-pencil"></span>',
['document-field-value/update', 'id' => $model['id'], 'document_id' => $model['document_id']]);
},
'delete' => function ($url,$model) {
return Html::a(
'<span class="glyphicon glyphicon-trash"></span>',
[
'document-field-value/delete', 'id' => $model['id'], 'document_id' => $model['document_id']
],
[
'data' => ['confirm' => 'Вы уверены, что хотите удалить этот вопрос?', 'method' => 'post']
]
);
},
],
],
],
]); ?>
<p>
<?= Html::a(
'Добавить поле',
['document-field-value/create', 'document_id' => $model->id],
['class' => 'btn btn-primary']
) ?>
</p>
</div>

View File

@ -0,0 +1,45 @@
<?php
use backend\modules\document\models\Template;
use common\models\DocumentField;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\TemplateDocumentField */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="template-document-field-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'template_id')->widget(Select2::className(),
[
'data' => Template::find()->select(['title', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите шаблон','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => false
],
]) ?>
<?= $form->field($model, 'field_id')->widget(Select2::className(),
[
'data' => DocumentField::find()->select(['title', 'document_field.id'])
->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите поле','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => false,
'multiple' => true,
'closeOnSelect' => false
],
]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,44 @@
<?php
use backend\modules\document\models\Template;
use common\models\DocumentField;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\TemplateDocumentField */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="template-document-field-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'template_id')->widget(Select2::className(),
[
'data' => Template::find()->select(['title', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите шаблон','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => false
],
]) ?>
<?= $form->field($model, 'field_id')->widget(Select2::className(),
[
'data' => DocumentField::find()->select(['title', 'document_field.id'])
->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите поле','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => false,
'closeOnSelect' => false
],
]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,31 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\TemplateDocumentFieldSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="template-document-field-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'template_id') ?>
<?= $form->field($model, 'field_id') ?>
<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,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\TemplateDocumentField */
$this->title = 'Добавить в шаблон поле';
$this->params['breadcrumbs'][] = ['label' => 'Template Document Fields', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="template-document-field-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,41 @@
<?php
use backend\modules\document\models\DocumentField;
use backend\modules\document\models\Template;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\document\models\TemplateDocumentFieldSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Поля шаблона документа';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="template-document-field-index">
<p>
<?= Html::a('Добавить поле в шаблон', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'template_id',
'filter' => Template::find()->select(['title', 'id'])->indexBy('id')->column(),
'value' => 'template.title',
],
[
'attribute' => 'field_id',
'filter' => DocumentField::find()->select(['title', 'id'])->indexBy('id')->column(),
'value' => 'field.title',
],
['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\document\models\TemplateDocumentField */
$this->title = 'Изменить поле документа';
$this->params['breadcrumbs'][] = ['label' => 'Template Document Fields', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="template-document-field-update">
<?= $this->render('_form_update', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,44 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\TemplateDocumentField */
$this->title = 'Поле шаблона';
$this->params['breadcrumbs'][] = ['label' => 'Template Document Fields', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="template-document-field-view">
<p>
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= 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',
[
'attribute' => 'template_id',
'value' => ArrayHelper::getValue($model, 'template.title'),
],
[
'attribute' => 'field_id',
'value' => ArrayHelper::getValue($model, 'field.title'),
],
],
]) ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use kartik\file\FileInput;
use mihaildev\elfinder\InputFile;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Template */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="template-form">
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data']]); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'template')->widget(FileInput::classname(), [
'options' => ['accept' => 'text/*'],
'pluginOptions' => [
'allowedFileExtensions'=>['doc','docx','txt'],'showUpload' => true
],
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use kartik\file\FileInput;
use mihaildev\elfinder\InputFile;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Template */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="template-form">
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data']]); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'template')->widget(FileInput::classname(), [
'options' => ['accept' => 'text/*'],
'pluginOptions' => [
'allowedFileExtensions'=>['doc','docx','txt'],'showUpload' => true
],
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\TemplateSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="template-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'title') ?>
<?= $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,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Template */
$this->title = 'Создать шаблон';
$this->params['breadcrumbs'][] = ['label' => 'Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="template-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\document\models\TemplateSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Шаблоны';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="template-index">
<p>
<?= Html::a('Создать шаблон', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'title',
// 'template_path',
'created_at',
'updated_at',
['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\document\models\Template */
$this->title = 'Изменить шаблон: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="template-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,130 @@
<?php
use backend\modules\document\models\DocumentField;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\YiiAsset;
use yii\widgets\DetailView;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $templateFieldDataProvider yii\data\ActiveDataProvider */
/* @var $model backend\modules\document\models\Template */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
YiiAsset::register($this);
?>
<div class="template-view">
<p>
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= 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',
[
'attribute'=>'title',
'format'=>'raw',
'value' => function($model){
return $model->title . Html::a(
'<i class="glyphicon glyphicon-pencil"></i>', ['update', 'id' => $model->id],
[
'title' => 'Update',
'class' => 'pull-right detail-button',
]
);
}
],
'created_at',
'updated_at',
[
'label'=>'template_file_name',
'format'=>'raw',
'value' => function($model){
return $model->template_file_name . Html::a('<i class="glyphicon glyphicon-pencil"></i>', Url::to(['actualizar', 'id' => $model->id]), [
'title' => 'Actualizar',
// 'class' => 'pull-right detail-button',
]);
}
]
],
]) ?>
<?php
$button1 = Html::a('<i class="glyphicon glyphicon-trash"></i>', Url::to(['delete', 'id' => $model->id]), [
'title' => 'Eliminar',
'class' => 'pull-right detail-button',
'data' => [
'confirm' => '¿Realmente deseas eliminar este elemento?',
'method' => 'post',
]
]);
$button2 = Html::a('<i class="glyphicon glyphicon-pencil"></i>', Url::to(['actualizar', 'id' => $model->id]), [
'title' => 'Actualizar',
'class' => 'pull-right detail-button',
]);
?>
<div>
<h2>
<?= 'Поля шаблона:'?>
</h2>
</div>
<?= GridView::widget([
'dataProvider' => $templateFieldDataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'field_id',
'filter' => DocumentField::find()->select(['title', 'id'])->indexBy('id')->column(),
'value' => 'field.title',
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view}{delete}',
'controller' => 'template-document-field',
'buttons' => [
'delete' => function ($url,$model) {
return Html::a(
'<span class="glyphicon glyphicon-trash"></span>',
[
'template-document-field/delete', 'id' => $model['id'], 'template_id' => $model['template_id']
],
[
'data' => ['confirm' => 'Вы уверены, что хотите удалить этот вопрос?', 'method' => 'post']
]
);
},
],
],
],
]); ?>
<p>
<?= Html::a(
'Добавить поле',
['template-document-field/create', 'template_id' => $model->id],
['class' => 'btn btn-primary']
) ?>
</p>
</div>

View File

@ -65,10 +65,6 @@ class ManagerEmployeeController extends Controller
*/
public function actionCreate()
{
$post = $post = \Yii::$app->request->post('ManagerEmployee');
if (!empty($post)) {

View File

@ -1,12 +0,0 @@
<div class="employee-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</div>

View File

@ -27,7 +27,6 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'user_card_id',
'filter' => UserCard::find()->select(['fio', 'id'])->indexBy('id')->column(),
'value' => 'userCard.fio',
],
['class' => 'yii\grid\ActionColumn'],

View File

@ -47,13 +47,11 @@ function cut_title($str)
[
'attribute' => 'answer_flag',
'format' => 'raw',
'filter' => AnswerHelper::answerFlagsList(),
'value' => AnswerHelper::answerFlagLabel($model->answer_flag),
],
[
'attribute' => 'status',
'format' => 'raw',
'filter' => StatusHelper::statusList(),
'value' => StatusHelper::statusLabel($model->status),
],
'created_at',

View File

@ -41,6 +41,23 @@
],
'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Документы', 'icon' => 'archive', 'url' => '#',
'items' => [
['label' => 'Документы', 'icon' => 'file-text', 'url' => ['/document/document'], 'active' => \Yii::$app->controller->id == 'document'],
['label' => 'Шаблоны', 'icon' => 'file', 'url' => ['/document/template'], 'active' => \Yii::$app->controller->id == 'template'],
['label' => 'Поля документов', 'icon' => 'file-text-o', 'url' => ['/document/document-field'], 'active' => \Yii::$app->controller->id == 'document-field'],
[
'label' => 'Сохранённые значения', 'icon' => 'info-circle', 'url' => '#',
'items' => [
['label' => 'Поля в шаблоне', 'icon' => 'file-text-o', 'url' => ['/document/template-document-field'], 'active' => \Yii::$app->controller->id == 'template-document-field'],
['label' => 'Значения полей', 'icon' => 'bars', 'url' => ['/document/document-field-value'], 'active' => \Yii::$app->controller->id == 'document-field-value'],
]
]
],
'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'], //'active' => \Yii::$app->controller->id == 'project',
'items' => $projectItems,

View File

@ -3,3 +3,4 @@ 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');
Yii::setAlias('@templates', dirname(dirname(__DIR__)) . '/frontend/web/upload/templates');

112
common/models/Document.php Normal file
View File

@ -0,0 +1,112 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use yii\db\StaleObjectException;
/**
* This is the model class for table "document".
*
* @property int $id
* @property string $title
* @property string $created_at
* @property string $updated_at
* @property int $template_id
* @property int $manager_id
*
* @property Manager $manager
* @property Template $template
* @property DocumentFieldValue[] $documentFieldValues
*/
class Document extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'document';
}
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/**
* @throws \Throwable
* @throws StaleObjectException
*/
public function beforeDelete()
{
foreach ($this->documentFieldValues as $documentFieldValue){
$documentFieldValue->delete();
}
return parent::beforeDelete();
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['created_at', 'updated_at'], 'safe'],
[['template_id', 'manager_id'], 'required'],
[['template_id', 'manager_id'], 'integer'],
['title', 'unique', 'targetAttribute' => ['title', 'template_id'], 'message'=>'Документ уже создан'],
[['title'], 'string', 'max' => 255],
[['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
[['template_id'], 'exist', 'skipOnError' => true, 'targetClass' => Template::className(), 'targetAttribute' => ['template_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'title' => 'Название',
'created_at' => 'Дата создания',
'updated_at' => 'Дата обновления',
'template_id' => 'Шаблон',
'manager_id' => 'Менеджер',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getManager()
{
return $this->hasOne(Manager::className(), ['id' => 'manager_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTemplate()
{
return $this->hasOne(Template::className(), ['id' => 'template_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getDocumentFieldValues()
{
return $this->hasMany(DocumentFieldValue::className(), ['document_id' => 'id']);
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace common\models;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "document_field".
*
* @property int $id
* @property string $title
*
* @property DocumentFieldValue[] $documentFieldValues
* @property TemplateDocumentField[] $templateDocumentFields
*/
class DocumentField extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'document_field';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['title'], 'string', 'max' => 255],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'title' => 'Название',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getDocumentFieldValues()
{
return $this->hasMany(DocumentFieldValue::className(), ['field_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTemplateDocumentFields()
{
return $this->hasMany(TemplateDocumentField::className(), ['field_id' => 'id']);
}
public static function getIdFieldsTitleList($template_id): array
{
return
self::find()->joinWith('templateDocumentFields')
->where(['template_document_field.template_id' => $template_id])
->asArray()->all();
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "document_field_value".
*
* @property int $id
* @property int $field_id
* @property int $document_id
* @property string $value
*
* @property Document $document
* @property DocumentField $field
*/
class DocumentFieldValue extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'document_field_value';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['field_id', 'document_id', 'value'], 'required'],
[['field_id', 'document_id'], 'integer'],
[['value'], 'string', 'max' => 255],
['field_id', 'unique', 'targetAttribute' => ['field_id', 'document_id'], 'message'=>'Поле уже используется'],
[['document_id'], 'exist', 'skipOnError' => true, 'targetClass' => Document::className(), 'targetAttribute' => ['document_id' => 'id']],
[['field_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocumentField::className(), 'targetAttribute' => ['field_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'field_id' => 'Поле',
'document_id' => 'Документ',
'value' => 'Значение',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getDocument()
{
return $this->hasOne(Document::className(), ['id' => 'document_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getField()
{
return $this->hasOne(DocumentField::className(), ['id' => 'field_id']);
}
}

105
common/models/Template.php Normal file
View File

@ -0,0 +1,105 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
/**
* This is the model class for table "template".
*
* @property int $id
* @property string $title
* @property string $created_at
* @property string $updated_at
* @property string $template_file_name
*
* @property Document[] $documents
* @property TemplateDocumentField[] $templateDocumentFields
*/
class Template extends \yii\db\ActiveRecord
{
public $template;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'template';
}
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['created_at', 'updated_at'], 'safe'],
[['title'], 'unique'],
[['template_file_name', 'title'], 'required'],
[['template'], 'required', 'message'=>'Укажите путь к файлу'],
[['template'], 'file', 'maxSize' => '10000'],
[['template'], 'file', 'skipOnEmpty' => false, 'extensions' => 'doc, docx, txt'],
[['title', 'template_file_name'], 'string', 'max' => 255],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'title' => 'Название',
'created_at' => 'Дата создания',
'updated_at' => 'Дата изменения',
'template_file_name' => 'Файл шаблона',
];
}
public function beforeDelete()
{
foreach ($this->templateDocumentFields as $templateDocumentField){
$templateDocumentField->delete();
}
if (!empty($this->template_file_name)) {
$template_path = Yii::getAlias('@templates') . '/' . $this->template_file_name;
if(file_exists($template_path)) {
unlink($template_path);
}
}
return parent::beforeDelete();
}
/**
* @return \yii\db\ActiveQuery
*/
public function getDocuments()
{
return $this->hasMany(Document::className(), ['template_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTemplateDocumentFields()
{
return $this->hasMany(TemplateDocumentField::className(), ['template_id' => 'id']);
}
}

View File

@ -0,0 +1,69 @@
<?php
namespace common\models;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "template_document_field".
*
* @property int $id
* @property int $template_id
* @property int $field_id
*
* @property DocumentField $field
* @property Template $template
*/
class TemplateDocumentField extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'template_document_field';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['template_id', 'field_id'], 'required'],
[['template_id', 'field_id'], 'integer'],
['field_id', 'unique', 'targetAttribute' => ['template_id', 'field_id'], 'message'=>'Поле уже назначено'],
[['field_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocumentField::className(), 'targetAttribute' => ['field_id' => 'id']],
[['template_id'], 'exist', 'skipOnError' => true, 'targetClass' => Template::className(), 'targetAttribute' => ['template_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'template_id' => 'Шаблон',
'field_id' => 'Поле',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getField()
{
return $this->hasOne(DocumentField::className(), ['id' => 'field_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTemplate()
{
return $this->hasOne(Template::className(), ['id' => 'template_id']);
}
}

View File

@ -225,6 +225,11 @@ class UserCard extends \yii\db\ActiveRecord
return $this->hasOne(Manager::class, ['user_card_id' => 'id']);
}
public function getManagerEmployee()
{
return $this->hasMany(ManagerEmployee::class, ['user_card_id' => 'id']);
}
public static function generateUserForUserCard($card_id = null)
{
$userCardQuery = self::find();

View File

@ -24,7 +24,7 @@
"kartik-v/yii2-widget-select2": "@dev",
"kavalar/hhapi": "@dev",
"mirocow/yii2-eav": "*",
"kartik-v/yii2-widget-fileinput": "^1.0",
"kartik-v/yii2-widget-fileinput": "dev-master",
"2amigos/yii2-file-upload-widget": "~1.0",
"kartik-v/yii2-grid": "dev-master",
"edofre/yii2-fullcalendar-scheduler": "V1.1.12",

20
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c1b5c9ed14985108b90f2db9fa60d08b",
"content-hash": "216b806f0c05ea29213238c495fe568f",
"packages": [
{
"name": "2amigos/yii2-file-upload-widget",
@ -1426,22 +1426,23 @@
},
{
"name": "kartik-v/yii2-widget-fileinput",
"version": "v1.1.0",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/kartik-v/yii2-widget-fileinput.git",
"reference": "d43bb9d9638ba117bbaa0045250645dc843fcf7f"
"reference": "d3caa4911ecd8125a5f87865807fa1de7f6cdba7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kartik-v/yii2-widget-fileinput/zipball/d43bb9d9638ba117bbaa0045250645dc843fcf7f",
"reference": "d43bb9d9638ba117bbaa0045250645dc843fcf7f",
"url": "https://api.github.com/repos/kartik-v/yii2-widget-fileinput/zipball/d3caa4911ecd8125a5f87865807fa1de7f6cdba7",
"reference": "d3caa4911ecd8125a5f87865807fa1de7f6cdba7",
"shasum": ""
},
"require": {
"kartik-v/bootstrap-fileinput": ">=5.0.0",
"kartik-v/yii2-krajee-base": ">=2.0.0"
"kartik-v/yii2-krajee-base": ">=3.0.1"
},
"default-branch": true,
"type": "yii2-extension",
"extra": {
"branch-alias": {
@ -1464,7 +1465,7 @@
"homepage": "http://www.krajee.com/"
}
],
"description": "An enhanced FileInput widget for Bootstrap 3.x & 4.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)",
"description": "An enhanced FileInput widget for Bootstrap 3.x, 4.x & 5.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)",
"homepage": "https://github.com/kartik-v/yii2-widget-fileinput",
"keywords": [
"extension",
@ -1479,7 +1480,7 @@
],
"support": {
"issues": "https://github.com/kartik-v/yii2-widget-fileinput/issues",
"source": "https://github.com/kartik-v/yii2-widget-fileinput/tree/v1.1.0"
"source": "https://github.com/kartik-v/yii2-widget-fileinput/tree/master"
},
"funding": [
{
@ -1487,7 +1488,7 @@
"type": "open_collective"
}
],
"time": "2020-10-23T19:54:51+00:00"
"time": "2021-09-03T10:14:31+00:00"
},
{
"name": "kartik-v/yii2-widget-select2",
@ -6497,6 +6498,7 @@
"stability-flags": {
"kartik-v/yii2-widget-select2": 20,
"kavalar/hhapi": 20,
"kartik-v/yii2-widget-fileinput": 20,
"kartik-v/yii2-grid": 20,
"kartik-v/yii2-widget-depdrop": 20
},

View File

@ -0,0 +1,30 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%template}}`.
*/
class m211223_090918_create_template_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%template}}', [
'id' => $this->primaryKey(),
'title' => $this->string(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime()
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%template}}');
}
}

View File

@ -0,0 +1,37 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%document}}`.
*/
class m211223_091152_create_document_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%document}}', [
'id' => $this->primaryKey(),
'title' => $this->string(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
'template_id' => $this->integer(11)->notNull(),
'manager_id' => $this->integer(11)->notNull(),
]);
$this->addForeignKey('document_template', 'document', 'template_id', 'template', 'id');
$this->addForeignKey('document_manager', 'document', 'manager_id', 'manager', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('document_manager', 'document');
$this->dropForeignKey('document_template', 'document');
$this->dropTable('{{%document}}');
}
}

View File

@ -0,0 +1,28 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%field}}`.
*/
class m211223_092038_create_document_field_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%document_field}}', [
'id' => $this->primaryKey(),
'title' => $this->string(),
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%document_field}}');
}
}

View File

@ -0,0 +1,34 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%template_field}}`.
*/
class m211223_092507_create_template_document_field_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%template_document_field}}', [
'id' => $this->primaryKey(),
'template_id' => $this->integer(11)->notNull(),
'field_id' => $this->integer(11)->notNull()
]);
$this->addForeignKey('template_template_document_field', 'template_document_field', 'template_id', 'template', 'id');
$this->addForeignKey('document_field_template_document_field', 'template_document_field', 'field_id', 'document_field', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('template_template_document_field', 'template_document_field');
$this->dropForeignKey('document_field_template_document_field', 'template_document_field');
$this->dropTable('{{%template_document_field}}');
}
}

View File

@ -0,0 +1,35 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%field_value}}`.
*/
class m211223_095155_create_document_field_value_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%document_field_value}}', [
'id' => $this->primaryKey(),
'field_id' => $this->integer(11)->notNull(),
'document_id' => $this->integer(11)->notNull(),
'value' => $this->string()
]);
$this->addForeignKey('document_field_document_field_value', 'document_field_value', 'field_id', 'document_field', 'id');
$this->addForeignKey('document_document_field_value', 'document_field_value', 'document_id', 'document', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('document_field_document_field_value', 'document_field_value');
$this->dropForeignKey('document_document_field_value', 'document_field_value');
$this->dropTable('{{%document_field_value}}');
}
}

View File

@ -0,0 +1,22 @@
<?php
use yii\db\Migration;
/**
* Class m211228_123343_add_column_template_file_to_template_table
*/
class m211228_123343_add_column_template_file_to_template_table extends Migration
{
public function safeUp()
{
$this->addColumn('template', 'template_file_name', $this->string(255));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('template', 'template_file_name');
}
}

View File

@ -1023,12 +1023,12 @@
```json5
[
{
"username": "testUser",
"fio": "testUser",
"id": 1,
"email": "admin@admin.com"
},
{
"username": "workerTest22",
"fio": "workerTest22",
"id": 2,
"email": "awdsdse@njbhj.com"
}
@ -1056,10 +1056,10 @@
</tr>
<tr>
<td>
username
fio
</td>
<td>
Имя пользователя(логин)(varchar(255))
ФИО пользователя(varchar(255))
</td>
</tr>
<tr>
@ -1127,12 +1127,12 @@
[
{
"id": 2,
"username": "workerTest",
"fio": "workerTest",
"email": "testUseweewer@testUser.com",
},
{
"id": 4,
"username": "worker1",
"fio": "worker1",
"email": "sdfsdvdworker2",
},
]
@ -1154,15 +1154,15 @@
id
</td>
<td>
ID пользователя(работника)(int)
ID пользователя(работника) у менеджера(int)
</td>
</tr>
<tr>
<td>
username
fio
</td>
<td>
Логин(varchar(255))
ФИО сотрудника(varchar(255))
</td>
</tr>
<tr>
@ -1229,9 +1229,11 @@
```json5
[
{
"id": 1,
"username": "testUser",
"email": "admin@admin.com",
"id": 5,
"fio": "Иванов Иван Иванович",
"email": "testmail@mail.com",
"photo": "",
"gender": 0
}
]
```
@ -1252,15 +1254,15 @@
id
</td>
<td>
ID как пользователя(int)
ID пользователя(работника) у менеджера(int)
</td>
</tr>
<tr>
<td>
username
fio
</td>
<td>
Логин(varchar(255))
ФИО сотрудника(varchar(255))
</td>
</tr>
<tr>
@ -1268,7 +1270,7 @@
email
</td>
<td>
Электронная почта(string)
Почтовый адрес(string)
</td>
</tr>
</table>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,9 @@
namespace frontend\modules\api\controllers;
use common\models\Manager;
use common\models\ManagerEmployee;
use common\models\User;
use common\models\UserCard;
use Yii;
use yii\filters\auth\HttpBearerAuth;
use yii\helpers\ArrayHelper;
@ -34,8 +34,8 @@ class ManagerController extends \yii\rest\Controller
public function actionGetManagerList(): array
{
$managers = User::find()->select(['username','manager.id' , 'email'])
->joinWith('manager')->where(['NOT',['manager.user_id' => null]])->all();
$managers = UserCard::find()->select(['fio','manager.id' , 'email'])
->joinWith('manager')->where(['NOT',['manager.user_card_id' => null]])->all();
if(empty($managers)) {
throw new NotFoundHttpException('Managers are not assigned');
@ -55,7 +55,8 @@ class ManagerController extends \yii\rest\Controller
throw new NotFoundHttpException('Incorrect manager ID');
}
$users_list = User::find()->select(['user.id', 'user.username', 'user.email'])
$users_list = UserCard::find()
->select(['manager_employee.id', 'user_card.fio', 'user_card.email'])
->joinWith('managerEmployee')
->where(['manager_employee.manager_id' => $manager_id])
->all();
@ -78,8 +79,8 @@ class ManagerController extends \yii\rest\Controller
throw new NotFoundHttpException('Incorrect manager ID');
}
$manager = User::find()
->select(['user.id', 'user.username', 'user.email'])
$manager = UserCard::find()
->select(['manager.id', 'fio', 'email', 'photo', 'gender'])
->joinWith('manager')->where(['manager.id' => $manager_id])
->all();

View File

@ -97,7 +97,7 @@ class TaskController extends Controller
}
if (empty($model->project_id)or empty($model->status)
or empty($model->description) or empty($model->title) or empty($model->user_id_creator)) {
or empty($model->description) or empty($model->title) or empty($model->card_id_creator)) {
throw new BadRequestHttpException(json_encode($model->errors));
}
}