drop unnecessary tables and module

This commit is contained in:
iIronside 2022-11-08 17:22:54 +03:00
parent 4efa463b18
commit 8648f5458e
66 changed files with 99 additions and 3516 deletions

View File

@ -1,24 +0,0 @@
<?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

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

View File

@ -1,162 +0,0 @@
<?php
namespace backend\modules\document\controllers;
use PhpOffice\PhpWord\Exception\CopyFileException;
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
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;
use common\services\DocumentFileService;
use yii\web\Response;
/**
* 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.');
}
/**
* @throws CopyFileException
* @throws NotFoundHttpException
* @throws CreateTemporaryFileException
*/
public function actionCreateDocument($id): Response
{
if(!empty($this->findModel($id)->template->template_file_name)){
$documentService = new DocumentFileService($id);
$documentService->setFields();
$documentService->downloadDocument();
}
return $this->redirect(['view', 'id' => $id]);
}
}

View File

@ -1,128 +0,0 @@
<?php
namespace backend\modules\document\controllers;
use common\helpers\TransliteratorHelper;
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

@ -1,189 +0,0 @@
<?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)) {
return $this->redirect([
'document/view',
'id' => $document_id,
]);
}
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

@ -1,199 +0,0 @@
<?php
namespace backend\modules\document\controllers;
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);
$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);
//
// if ($model->load(Yii::$app->request->post()) && $model->save()) {
// return $this->redirect(['view', 'id' => $model->id]);
// }
//
// return $this->render('update', [
// 'model' => $model,
// ]);
// }
public function actionUpdateTitle($id)
{
$model = $this->findModel($id);
$model->scenario = Template::SCENARIO_UPDATE_TITLE;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('_form_update_title', [
'model' => $model,
]);
}
public function actionUpdateFile($id)
{
$model = $this->findModel($id);
$model->scenario = Template::SCENARIO_UPDATE_FILE;
if ($model->load(Yii::$app->request->post())) {
$model->template = UploadedFile::getInstance($model, 'template');
if (!empty($model->template)) {
$pathToTemplates = Yii::getAlias('@templates');
unlink($pathToTemplates . '/' . $model->template_file_name);
$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(['view', 'id' => $model->id]);
}
return $this->render('_form_update_file', ['model' => $model]);
}
}
return $this->render('_form_update_file', [
'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

@ -1,153 +0,0 @@
<?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

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

View File

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

View File

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

View File

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

View File

@ -1,69 +0,0 @@
<?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', 'field_template'], '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])
->andFilterWhere(['like', 'field_template', $this->field_template]);
return $dataProvider;
}
}

View File

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

View File

@ -1,70 +0,0 @@
<?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

@ -1,72 +0,0 @@
<?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

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

View File

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

View File

@ -1,67 +0,0 @@
<?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

@ -1,72 +0,0 @@
<?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', 'document_type'], 'integer'],
[['title', 'document_type', '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])
->andFilterWhere(['like', 'document_type', $this->document_type]);
return $dataProvider;
}
}

View File

@ -1,43 +0,0 @@
<?php
use backend\modules\document\models\Document;
use kartik\file\FileInput;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\AccompanyingDocument */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="accompanying-document-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, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'accompanying_document')->widget(FileInput::classname(), [
'options' => ['accept' => 'text/*'],
'pluginOptions' => [
'allowedFileExtensions'=>['docx'],'showUpload' => true
],
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -1,31 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\AccompanyingDocumentSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="accompanying-document-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'document_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

@ -1,18 +0,0 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\AccompanyingDocument */
$this->title = 'Добавить сопроводительный документ';
$this->params['breadcrumbs'][] = ['label' => 'Accompanying Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="accompanying-document-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

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

View File

@ -1,21 +0,0 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\AccompanyingDocument */
$this->title = 'Update Accompanying Document: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Accompanying Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="accompanying-document-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -1,38 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\AccompanyingDocument */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Accompanying Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="accompanying-document-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',
'document_id',
'title',
],
]) ?>
</div>

View File

@ -1,46 +0,0 @@
<?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

@ -1,38 +0,0 @@
<?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

@ -1,33 +0,0 @@
<?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

@ -1,18 +0,0 @@
<?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

@ -1,43 +0,0 @@
<?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

@ -1,20 +0,0 @@
<?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

@ -1,47 +0,0 @@
<?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')
],
[
'attribute' => 'document_id',
'value' => ArrayHelper::getValue($model, 'document.title')
],
'value',
],
]) ?>
</div>

View File

@ -1,23 +0,0 @@
<?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

@ -1,31 +0,0 @@
<?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') ?>
<?= $form->field($model, 'field_template') ?>
<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

@ -1,18 +0,0 @@
<?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

@ -1,38 +0,0 @@
<?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">
<?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'],
'title',
[
'attribute' => 'field_template',
'value' => function($model) {
return '${' . $model->field_template . '}';
},
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -1,19 +0,0 @@
<?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

@ -1,40 +0,0 @@
<?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',
[
'attribute' => 'field_template',
'value' => '${' . $model->field_template . '}',
],
],
]) ?>
</div>

View File

@ -1,47 +0,0 @@
<?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

@ -1,37 +0,0 @@
<?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

@ -1,18 +0,0 @@
<?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

@ -1,88 +0,0 @@
<?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

@ -1,19 +0,0 @@
<?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

@ -1,111 +0,0 @@
<?php
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
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">
<!-- --><?php // \common\models\Document::getDocumentWitchAndFieldValues(31); die?>
<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',
[
'attribute' => 'template_id',
'value' => ArrayHelper::getValue($model,'template.title'),
],
[
'attribute' => 'manager_id',
'value' => ArrayHelper::getValue($model,'manager.userCard.fio')
],
],
]) ?>
<p>
<?= Html::a(
'Скачать файл',
['document/create-document', 'id' => $model->id],
['class' => 'btn btn-primary']
) ?>
</p>
<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

@ -1,45 +0,0 @@
<?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

@ -1,44 +0,0 @@
<?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

@ -1,31 +0,0 @@
<?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

@ -1,18 +0,0 @@
<?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

@ -1,41 +0,0 @@
<?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

@ -1,19 +0,0 @@
<?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

@ -1,44 +0,0 @@
<?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

@ -1,41 +0,0 @@
<?php
use common\helpers\TemplateDocumentTypeHelper;
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, 'document_type')->dropDownList(
TemplateDocumentTypeHelper::getDocumentTypeList(),
[
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'template')->widget(FileInput::classname(), [
'options' => ['accept' => 'text/*'],
'pluginOptions' => [
'allowedFileExtensions'=>['docx'],'showUpload' => true
],
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -1,30 +0,0 @@
<?php
use kartik\file\FileInput;
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, 'template')->widget(FileInput::classname(), [
'options' => ['accept' => 'text/*'],
'pluginOptions' => [
'allowedFileExtensions'=>['docx'],'showUpload' => true
],
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -1,24 +0,0 @@
<?php
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]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -1,33 +0,0 @@
<?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

@ -1,16 +0,0 @@
<?php
/* @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

@ -1,45 +0,0 @@
<?php
use common\helpers\TemplateDocumentTypeHelper;
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',
'created_at',
'updated_at',
[
'attribute' => 'document_type',
// 'format' => 'raw',
'filter' => TemplateDocumentTypeHelper::getDocumentTypeList(),
'value' => function($model){
return TemplateDocumentTypeHelper::getDocumentType($model->document_type);
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {delete}',
],
],
]); ?>
</div>

View File

@ -1,27 +0,0 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Template */
$this->title = 'Изменить шаблон: ' . cut_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';
function cut_title($str)
{
if(strlen($str) > 35){
return mb_substr($str, 0, 25, 'UTF-8') . '...';
}
return $str;
}
?>
<div class="template-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -1,143 +0,0 @@
<?php
use backend\modules\document\models\DocumentField;
use common\helpers\TemplateDocumentTypeHelper;
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 = cut_title($model->title);
$this->params['breadcrumbs'][] = ['label' => 'Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
YiiAsset::register($this);
function cut_title($str)
{
if(strlen($str) > 35){
return mb_substr($str, 0, 35, 'UTF-8') . '...';
}
return $str;
}
?>
<div class="template-view">
<p>
<?= Html::a('Список', ['index', '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',
[
'label'=>'title',
'format'=>'raw',
'value' => function($model){
return $model->title . Html::a(' <i class="glyphicon glyphicon-pencil"></i>',
Url::to(['template/update-title', 'id' => $model->id]), [
'title' => 'update-title',
// '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(['template/update-file', 'id' => $model->id]), [
'title' => 'update-file',
// 'class' => 'pull-right detail-button',
]);
}
],
[
'attribute' => 'document_type',
'format' => 'raw',
'value' => TemplateDocumentTypeHelper::getDocumentType($model->document_type),
],
],
]) ?>
<?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',
'value' => 'field.title',
],
[
'attribute' => 'field.field_template',
'value' => 'field.field_template',
],
[
'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

@ -1,65 +0,0 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "accompanying_document".
*
* @property int $id
* @property int $document_id
* @property string $title
*
* @property Document $document
*/
class AccompanyingDocument extends \yii\db\ActiveRecord
{
public $accompanying_document;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'accompanying_document';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['document_id'], 'integer'],
[['title'], 'required'],
[['title'], 'string', 'max' => 255],
[['template_file_name', 'title'], 'required'],
[['accompanying_document'], 'required', 'message'=>'Укажите путь к файлу'],
[['accompanying_document'], 'file', 'maxSize' => '100000'],
[['accompanying_document'], 'file', 'skipOnEmpty' => true, 'extensions' => 'docx'],
[['document_id'], 'exist', 'skipOnError' => true, 'targetClass' => Document::className(), 'targetAttribute' => ['document_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'document_id' => 'Документ',
'title' => 'Название',
'accompanying_document' => 'Сопроводительный документ'
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getDocument()
{
return $this->hasOne(Document::className(), ['id' => 'document_id']);
}
}

View File

@ -1,113 +0,0 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveQuery;
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 ActiveQuery
*/
public function getManager()
{
return $this->hasOne(Manager::className(), ['id' => 'manager_id']);
}
/**
* @return ActiveQuery
*/
public function getTemplate()
{
return $this->hasOne(Template::className(), ['id' => 'template_id']);
}
/**
* @return ActiveQuery
*/
public function getDocumentFieldValues(): ActiveQuery
{
return $this->hasMany(DocumentFieldValue::className(), ['document_id' => 'id']);
}
}

View File

@ -1,80 +0,0 @@
<?php
namespace common\models;
use common\helpers\TransliteratorHelper;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "document_field".
*
* @property int $id
* @property string $title
* @property string $field_template
*
* @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', 'field_template'], 'string', 'max' => 255],
];
}
public function beforeSave($insert)
{
$this->field_template = TransliteratorHelper::transliterate($this->title);
return true;
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'title' => 'Название',
'field_template' => 'Шаблон поля',
];
}
/**
* @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

@ -1,72 +0,0 @@
<?php
namespace common\models;
use Yii;
use yii\db\ActiveQuery;
/**
* 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 ActiveQuery
*/
public function getDocument()
{
return $this->hasOne(Document::className(), ['id' => 'document_id']);
}
/**
* @return ActiveQuery
*/
public function getField(): ActiveQuery
{
return $this->hasOne(DocumentField::className(), ['id' => 'field_id']);
}
}

View File

@ -1,132 +0,0 @@
<?php
namespace common\models;
use Yii;
use yii\base\InvalidConfigException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveQuery;
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 int $document_type
*
* @property Document[] $documents
* @property TemplateDocumentField[] $templateDocumentFields
*/
class Template extends \yii\db\ActiveRecord
{
const SCENARIO_UPDATE_TITLE = 'update';
const SCENARIO_UPDATE_FILE = 'update';
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'],
[['document_type'], 'integer'],
[['template_file_name', 'title', 'document_type'], 'required'],
[['template'], 'required', 'message'=>'Укажите путь к файлу'],
[['template'], 'file', 'maxSize' => '100000'],
[['template'], 'file', 'skipOnEmpty' => true, 'extensions' => 'docx'],
[['title', 'template_file_name'], 'string', 'max' => 255],
];
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios[static::SCENARIO_UPDATE_TITLE] = ['created_at', 'updated_at', 'title', 'template_file_name'];
$scenarios[static::SCENARIO_UPDATE_FILE] = ['template'];
return $scenarios;
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'title' => 'Название',
'created_at' => 'Дата создания',
'updated_at' => 'Дата изменения',
'template_file_name' => 'Файл шаблона',
'document_type' => 'Тип документа',
];
}
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 ActiveQuery
*/
public function getDocuments()
{
return $this->hasMany(Document::className(), ['template_id' => 'id']);
}
/**
* @return ActiveQuery
*/
public function getTemplateDocumentFields()
{
return $this->hasMany(TemplateDocumentField::className(), ['template_id' => 'id']);
}
public function getTitle()
{
return $this->title;
}
public function getFields()
{
return $this->hasMany(DocumentField::className(), ['id' => 'field_id'])
->via('templateDocumentFields');
}
}

View File

@ -1,69 +0,0 @@
<?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'])->asArray();
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTemplate()
{
return $this->hasOne(Template::className(), ['id' => 'template_id']);
}
}

View File

@ -0,0 +1,99 @@
<?php
use yii\db\Migration;
/**
* Class m221108_125006_drop_unnecessary_tables_for_document
*/
class m221108_125006_drop_unnecessary_tables_for_document extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->dropTable('accompanying_document');
$this->dropTable('document_field_value');
$this->dropTable('template_document_field');
$this->dropTable('document_field');
$this->dropTable('document');
$this->dropTable('template');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->createTable('{{%template}}', [
'id' => $this->primaryKey(),
'title' => $this->string(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
'template_file_name' => $this->string(255),
'document_type' => $this->integer()->defaultValue(null)
]);
$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');
$this->createTable('{{%document_field}}', [
'id' => $this->primaryKey(),
'title' => $this->string(),
'field_template' => $this->string(),
]);
$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');
$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');
$this->createTable('{{%accompanying_document}}', [
'id' => $this->primaryKey(),
'document_id' => $this->integer(11),
'title' => $this->string()->notNull(),
]);
$this->addForeignKey('document_accompanying_document', 'accompanying_document', 'document_id', 'document', 'id');
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m221108_125006_drop_unnecessary_tables_for_document cannot be reverted.\n";
return false;
}
*/
}