Merge pull request #100 from apuc/document

Document
This commit is contained in:
2022-11-21 14:05:44 +03:00
committed by GitHub
76 changed files with 4360 additions and 2382 deletions

View File

@ -62,7 +62,7 @@ $this->params['breadcrumbs'][] = 'Резюме';
</div>
<div class="resume-form">
<div>
<p>
<?= Html::a('Скачать pdf', ['download-resume', 'id' => $model->id, 'type' => 'pdf'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Скачать docx', ['download-resume', 'id' => $model->id, 'type' => 'docx'], ['class' => 'btn btn-success']) ?>

View File

@ -2,18 +2,13 @@
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 common\services\DocumentService;
use Yii;
use yii\filters\VerbFilter;
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.
@ -58,17 +53,8 @@ class DocumentController extends Controller
*/
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
'model' => $this->findModel($id),
]);
}
@ -81,12 +67,10 @@ class DocumentController extends Controller
{
$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
]);
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
DocumentService::generateDocumentBody($model);
$model->save(false);
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
@ -144,19 +128,59 @@ class DocumentController extends Controller
throw new NotFoundHttpException('The requested page does not exist.');
}
public function actionDownload($id): string
{
return $this->render('download', [
'model' => Document::findOne($id)
]);
}
/**
* @throws CopyFileException
* @param integer $id
* @throws NotFoundHttpException
* @throws CreateTemporaryFileException
*/
public function actionCreateDocument($id): Response
public function actionUpdateDocumentBody($id): string
{
if(!empty($this->findModel($id)->template->template_file_name)){
$documentService = new DocumentFileService($id);
$documentService->setFields();
$documentService->downloadDocument();
$model = $this->findModel($id);
$model->scenario = $model::SCENARIO_UPDATE_DOCUMENT_BODY;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->updated_at = date('Y-m-d h:i:s');
$model->save();
}
return $this->redirect(['view', 'id' => $id]);
return $this->render('download', [
'model' => $model
]);
}
public function actionDownloadPdf($id): string
{
$model = $this->findModel($id);
$model->scenario = $model::SCENARIO_DOWNLOAD_DOCUMENT;
if ($model->validate()) {
DocumentService::downloadPdf($id);
}
Yii::$app->session->setFlash('error', $model->getFirstError('body'));
return $this->render('download', [
'model' => Document::findOne($id)
]);
}
public function actionDownloadDocx($id): string
{
$model = $this->findModel($id);
$model->scenario = $model::SCENARIO_DOWNLOAD_DOCUMENT;
if ($model->validate()) {
DocumentService::downloadPdf($id);
}
Yii::$app->session->setFlash('error', $model->getFirstError('body'));
return $this->render('download', [
'model' => Document::findOne($id)
]);
}
}

View File

@ -2,7 +2,6 @@
namespace backend\modules\document\controllers;
use common\helpers\TransliteratorHelper;
use Yii;
use backend\modules\document\models\DocumentField;
use backend\modules\document\models\DocumentFieldSearch;

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

@ -3,16 +3,16 @@
namespace backend\modules\document\controllers;
use Yii;
use backend\modules\document\models\AccompanyingDocument;
use backend\modules\document\models\AccompanyingDocumentSearch;
use backend\modules\document\models\DocumentTemplate;
use backend\modules\document\models\DocumentTemplateSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* AccompanyingDocumentController implements the CRUD actions for AccompanyingDocument model.
* DocumentTemplateController implements the CRUD actions for DocumentTemplate model.
*/
class AccompanyingDocumentController extends Controller
class DocumentTemplateController extends Controller
{
/**
* {@inheritdoc}
@ -30,12 +30,12 @@ class AccompanyingDocumentController extends Controller
}
/**
* Lists all AccompanyingDocument models.
* Lists all DocumentTemplate models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new AccompanyingDocumentSearch();
$searchModel = new DocumentTemplateSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
@ -45,7 +45,7 @@ class AccompanyingDocumentController extends Controller
}
/**
* Displays a single AccompanyingDocument model.
* Displays a single DocumentTemplate model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
@ -58,13 +58,13 @@ class AccompanyingDocumentController extends Controller
}
/**
* Creates a new AccompanyingDocument model.
* Creates a new DocumentTemplate model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new AccompanyingDocument();
$model = new DocumentTemplate();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
@ -76,7 +76,7 @@ class AccompanyingDocumentController extends Controller
}
/**
* Updates an existing AccompanyingDocument model.
* Updates an existing DocumentTemplate model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
@ -96,7 +96,7 @@ class AccompanyingDocumentController extends Controller
}
/**
* Deletes an existing AccompanyingDocument model.
* Deletes an existing DocumentTemplate model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
@ -110,15 +110,15 @@ class AccompanyingDocumentController extends Controller
}
/**
* Finds the AccompanyingDocument model based on its primary key value.
* Finds the DocumentTemplate 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
* @return DocumentTemplate the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = AccompanyingDocument::findOne($id)) !== null) {
if (($model = DocumentTemplate::findOne($id)) !== null) {
return $model;
}

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

@ -2,9 +2,6 @@
namespace backend\modules\document\models;
use Yii;
class Document extends \common\models\Document
{

View File

@ -2,9 +2,6 @@
namespace backend\modules\document\models;
use Yii;
class DocumentField extends \common\models\DocumentField
{

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

@ -17,8 +17,8 @@ class DocumentSearch extends Document
public function rules()
{
return [
[['id', 'template_id', 'manager_id'], 'integer'],
[['title', 'created_at', 'updated_at'], 'safe'],
[['id', 'company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'template_id'], 'integer'],
[['title', 'body', 'created_at', 'updated_at'], 'safe'],
];
}
@ -59,13 +59,17 @@ class DocumentSearch extends Document
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'company_id' => $this->company_id,
'contractor_company_id' => $this->contractor_company_id,
'manager_id' => $this->manager_id,
'contractor_manager_id' => $this->contractor_manager_id,
'template_id' => $this->template_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]);
$query->andFilterWhere(['like', 'title', $this->title])
->andFilterWhere(['like', 'body', $this->body]);
return $dataProvider;
}

View File

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

View File

@ -4,12 +4,12 @@ namespace backend\modules\document\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\document\models\Template;
use backend\modules\document\models\DocumentTemplate;
/**
* TemplateSearch represents the model behind the search form of `backend\modules\document\models\Template`.
* DocumentTemplateSearch represents the model behind the search form of `backend\modules\document\models\DocumentTemplate`.
*/
class TemplateSearch extends Template
class DocumentTemplateSearch extends DocumentTemplate
{
/**
* {@inheritdoc}
@ -17,8 +17,8 @@ class TemplateSearch extends Template
public function rules()
{
return [
[['id', 'document_type'], 'integer'],
[['title', 'document_type', 'created_at', 'updated_at', 'template_file_name'], 'safe'],
[['id', 'status'], 'integer'],
[['title', 'template_body', 'created_at', 'updated_at'], 'safe'],
];
}
@ -40,7 +40,7 @@ class TemplateSearch extends Template
*/
public function search($params)
{
$query = Template::find();
$query = DocumentTemplate::find();
// add conditions that should always apply here
@ -59,13 +59,13 @@ class TemplateSearch extends Template
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'status' => $this->status,
'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]);
->andFilterWhere(['like', 'template_body', $this->template_body]);
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,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

@ -14,6 +14,8 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'field_template')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>

View File

@ -5,7 +5,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentField */
$this->title = 'Создание поля документа';
$this->title = 'Создать ноое поле';
$this->params['breadcrumbs'][] = ['label' => 'Document Fields', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>

View File

@ -12,10 +12,8 @@ $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']) ?>
<?= Html::a('Создать поле', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
@ -25,12 +23,7 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\SerialColumn'],
'title',
[
'attribute' => 'field_template',
'value' => function($model) {
return '${' . $model->field_template . '}';
},
],
'field_template',
['class' => 'yii\grid\ActionColumn'],
],

View File

@ -5,7 +5,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentField */
$this->title = 'Изменение поля документа. Поле: ' . $model->title;
$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';

View File

@ -30,10 +30,7 @@ $this->params['breadcrumbs'][] = $this->title;
'attributes' => [
'id',
'title',
[
'attribute' => 'field_template',
'value' => '${' . $model->field_template . '}',
],
'field_template',
],
]) ?>

View File

@ -0,0 +1,102 @@
<?php
use asmoday74\ckeditor5\EditorClassic;
use backend\modules\document\models\DocumentField;
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentTemplate */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="row">
<div class="col-md-8">
<div class="document-template-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->dropDownList(
StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'template_body')->widget(EditorClassic::className(), [
'clientOptions' => [
'language' => 'ru',
]
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
<div class="col-md-4">
<div class="table-responsive">
<table class="table" id="fieldNameTable">
<thead>
<tr>
<th>Поле</th>
<th>Сигнатура поля</th>
</tr>
</thead>
<tbody>
<?php
foreach (DocumentField::getTitleFieldTemplateArr() as $fieldTitle => $fieldTemplate) {
echo "
<tr class='info'>
<td class='table-cell'>$fieldTitle</td>
<td class='table-cell'>$fieldTemplate</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
<div>
<p>
Нажмите на ячейку чтобы скопировать содержимое
</p>
</div>
</div>
</div>
<script>
const popup = document.createElement('h4')
popup.textContent = 'Скопировано'
popup.style.cssText = `
background: #a6caf0;
position: absolute;
right: 0;
top: 0;
`
document.querySelectorAll('.table-cell').forEach(function (elm) {
elm.style.position = 'relative'
elm.addEventListener('click', function (e) {
e.target.style.backgroundColor = '#76d7c4'
var copyText = e.target.textContent
const el = document.createElement('textarea')
el.value = copyText
document.body.appendChild(el)
el.select()
document.execCommand('copy')
document.body.removeChild(el)
elm.appendChild(popup)
setTimeout(() => {
elm.removeChild(popup)
}, 1000)
})
})
</script>

View File

@ -4,11 +4,11 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\TemplateSearch */
/* @var $model backend\modules\document\models\DocumentTemplateSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="template-search">
<div class="document-template-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
@ -19,9 +19,13 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'title') ?>
<?= $form->field($model, 'template_body') ?>
<?= $form->field($model, 'status') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'updated_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>

View File

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentTemplate */
$this->title = 'Создать шаблон документа';
$this->params['breadcrumbs'][] = ['label' => 'Document Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-template-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -1,17 +1,17 @@
<?php
use common\helpers\TemplateDocumentTypeHelper;
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\document\models\TemplateSearch */
/* @var $searchModel backend\modules\document\models\DocumentTemplateSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Шаблоны';
$this->title = 'Шаблоны документов';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="template-index">
<div class="document-template-index">
<p>
<?= Html::a('Создать шаблон', ['create'], ['class' => 'btn btn-success']) ?>
@ -24,22 +24,20 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\SerialColumn'],
'title',
'created_at',
'updated_at',
[
'attribute' => 'document_type',
// 'format' => 'raw',
'filter' => TemplateDocumentTypeHelper::getDocumentTypeList(),
'attribute' => 'status',
'format' => 'raw',
'filter' => StatusHelper::statusList(),
'value' => function($model){
return TemplateDocumentTypeHelper::getDocumentType($model->document_type);
return StatusHelper::statusLabel($model->status);
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {delete}',
],
'created_at',
//'updated_at',
// 'template_body:ntext',
['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\DocumentTemplate */
$this->title = 'Изменить шаблон: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Document Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="document-template-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -1,18 +1,18 @@
<?php
use yii\helpers\ArrayHelper;
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\TemplateDocumentField */
/* @var $model backend\modules\document\models\DocumentTemplate */
$this->title = 'Поле шаблона';
$this->params['breadcrumbs'][] = ['label' => 'Template Document Fields', 'url' => ['index']];
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Document Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="template-document-field-view">
<div class="document-template-view">
<p>
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
@ -30,13 +30,24 @@ $this->params['breadcrumbs'][] = $this->title;
'model' => $model,
'attributes' => [
'id',
'title',
[
'attribute' => 'template_id',
'value' => ArrayHelper::getValue($model, 'template.title'),
'attribute' => 'status',
'format' => 'raw',
'value' => StatusHelper::statusLabel($model->status),
],
'created_at',
'updated_at',
[
'attribute' => 'template_body',
'format' => 'raw'
],
[
'attribute' => 'field_id',
'value' => ArrayHelper::getValue($model, 'field.title'),
'attribute' => 'Переменные в шаблоне',
'value' => function($model){
preg_match_all('/(\${\w+})/', $model->template_body,$out);
return implode(",", $out[0]);
},
],
],
]) ?>

View File

@ -1,6 +1,7 @@
<?php
use backend\modules\document\models\Template;
use backend\modules\company\models\Company;
use backend\modules\document\models\DocumentTemplate;
use backend\modules\employee\models\Manager;
use kartik\select2\Select2;
use yii\helpers\Html;
@ -15,28 +16,59 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'manager_id')->widget(Select2::className(),
<?= $form->field($model, 'company_id')->widget(Select2::class,
[
'data' => Manager::find()->select(['user_card.fio', 'manager.id'])
->joinWith('userCard')
->indexBy('manager.id')->column(),
'options' => ['placeholder' => 'Выберите менеджера','class' => 'form-control'],
'data' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]) ?>
],
]
); ?>
<?= $form->field($model, 'manager_id')->widget(Select2::class,
[
'data' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<?= $form->field($model, 'contractor_company_id')->widget(Select2::class,
[
'data' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<?= $form->field($model, 'contractor_manager_id')->widget(Select2::class,
[
'data' => Manager::find()->select(['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(),
<?= $form->field($model, 'template_id')->widget(Select2::class,
[
'data' => Template::find()->select(['title', 'id'])
->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите шаблон','class' => 'form-control'],
'data' => DocumentTemplate::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']) ?>

View File

@ -17,15 +17,23 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'title') ?>
<?= $form->field($model, 'company_id') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'contractor_company_id') ?>
<?= $form->field($model, 'updated_at') ?>
<?= $form->field($model, 'manager_id') ?>
<?= $form->field($model, 'template_id') ?>
<?= $form->field($model, 'contractor_manager_id') ?>
<?php // echo $form->field($model, 'manager_id') ?>
<?php // echo $form->field($model, 'template_id') ?>
<?php // echo $form->field($model, 'title') ?>
<?php // echo $form->field($model, 'body') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>

View File

@ -0,0 +1,48 @@
<?php
use asmoday74\ckeditor5\EditorClassic;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
$this->title = 'Документ: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Документы', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Загрузить';
?>
<div class="form-group">
<?= Html::a('Редактировать документ', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Просмотр документа', ['view', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
</div
<div class="resume-form">
<?php $form = ActiveForm::begin([
'id' => 'update-resume-text-form',
'action' => Url::to(['document/update-document-body', 'id' => $model->id]),
'options' => ['method' => 'post']])
?>
<?= $form->field($model, 'body')->widget(EditorClassic::className(), [
'clientOptions' => [
'language' => 'ru',
]
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохраниить изменения', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
<div>
<p>
<?= Html::a('Скачать pdf', ['download-pdf', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Скачать docx', ['download-docx', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
</p>
</div>
</div>

View File

@ -1,8 +1,7 @@
<?php
use backend\modules\document\models\Document;
use backend\modules\document\models\Template;
use kartik\select2\Select2;
use backend\modules\company\models\Company;
use backend\modules\employee\models\Manager;
use yii\helpers\Html;
use yii\grid\GridView;
@ -25,64 +24,47 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'title',
// 'body:ntext',
[
'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' => 'company_id',
'filter' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'value' => 'company.name'
],
[
'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' => 'contractor_company_id',
'filter' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'value' => 'contractorCompany.name'
],
[
'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',
'filter' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'value' => 'manager.userCard.fio'
],
'created_at',
'updated_at',
[
'attribute' => 'contractor_manager_id',
'filter' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'value' => 'manager.userCard.fio'
],
//'title',
//'body:ntext',
//'created_at',
//'updated_at',
['class' => 'yii\grid\ActionColumn'],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {download}',
'buttons' => [
'download' => function($url, $model) {
return Html::a(
'<span class="glyphicon glyphicon-download-alt"></span>',
['document/download', 'id' => $model->id]
);
}
]
]
],
]); ?>
</div>

View File

@ -5,7 +5,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
$this->title = 'Изменить Документ: ' . $model->title;
$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';

View File

@ -1,26 +1,25 @@
<?php
use yii\grid\GridView;
use common\classes\Debug;
use common\models\Document;
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->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('Скачать', ['download', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
@ -28,6 +27,7 @@ $this->params['breadcrumbs'][] = $this->title;
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
@ -35,77 +35,30 @@ $this->params['breadcrumbs'][] = $this->title;
'attributes' => [
'id',
'title',
'created_at',
'updated_at',
[
'attribute' => 'template_id',
'value' => ArrayHelper::getValue($model,'template.title'),
'attribute' => 'company_id',
'value' => ArrayHelper::getValue($model, 'company.name'),
],
[
'attribute' => 'manager_id',
'value' => ArrayHelper::getValue($model,'manager.userCard.fio')
'value' => ArrayHelper::getValue($model, 'manager.userCard.fio'),
],
[
'attribute' => 'contractor_company_id',
'value' => ArrayHelper::getValue($model, 'contractorCompany.name'),
],
[
'attribute' => 'contractor_manager_id',
'value' => ArrayHelper::getValue($model, 'manager.userCard.fio'),
],
[
'attribute' => 'body',
'format' => 'raw',
],
'created_at',
'updated_at',
],
]) ?>
<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,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,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,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>