commit
a30bc6482b
@ -62,7 +62,7 @@ $this->params['breadcrumbs'][] = 'Резюме';
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="resume-form">
|
<div>
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a('Скачать pdf', ['download-resume', 'id' => $model->id, 'type' => 'pdf'], ['class' => 'btn btn-success']) ?>
|
<?= 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']) ?>
|
<?= Html::a('Скачать docx', ['download-resume', 'id' => $model->id, 'type' => 'docx'], ['class' => 'btn btn-success']) ?>
|
||||||
|
@ -2,18 +2,13 @@
|
|||||||
|
|
||||||
namespace backend\modules\document\controllers;
|
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\Document;
|
||||||
use backend\modules\document\models\DocumentSearch;
|
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\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
|
||||||
|
|
||||||
use common\services\DocumentFileService;
|
|
||||||
use yii\web\Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DocumentController implements the CRUD actions for Document model.
|
* DocumentController implements the CRUD actions for Document model.
|
||||||
@ -58,17 +53,8 @@ class DocumentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function actionView($id)
|
public function actionView($id)
|
||||||
{
|
{
|
||||||
$model = $this->findModel($id);
|
|
||||||
$documentFieldValuesDataProvider = new ActiveDataProvider([
|
|
||||||
'query' => $model->getDocumentFieldValues(),//->with('questionType'),
|
|
||||||
'pagination' => [
|
|
||||||
'pageSize' => 20,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->render('view', [
|
return $this->render('view', [
|
||||||
'model' => $model,
|
'model' => $this->findModel($id),
|
||||||
'documentFieldValuesDataProvider' => $documentFieldValuesDataProvider
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,12 +67,10 @@ class DocumentController extends Controller
|
|||||||
{
|
{
|
||||||
$model = new Document();
|
$model = new Document();
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||||
return $this->redirect([
|
DocumentService::generateDocumentBody($model);
|
||||||
'document-field-value/create-multiple',
|
$model->save(false);
|
||||||
'document_id' => $model->id,
|
return $this->redirect(['view', 'id' => $model->id]);
|
||||||
'template_id' => $model->template_id
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('create', [
|
return $this->render('create', [
|
||||||
@ -144,19 +128,59 @@ class DocumentController extends Controller
|
|||||||
throw new NotFoundHttpException('The requested page does not exist.');
|
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 NotFoundHttpException
|
||||||
* @throws CreateTemporaryFileException
|
|
||||||
*/
|
*/
|
||||||
public function actionCreateDocument($id): Response
|
public function actionUpdateDocumentBody($id): string
|
||||||
{
|
{
|
||||||
if(!empty($this->findModel($id)->template->template_file_name)){
|
$model = $this->findModel($id);
|
||||||
$documentService = new DocumentFileService($id);
|
$model->scenario = $model::SCENARIO_UPDATE_DOCUMENT_BODY;
|
||||||
$documentService->setFields();
|
|
||||||
$documentService->downloadDocument();
|
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)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace backend\modules\document\controllers;
|
namespace backend\modules\document\controllers;
|
||||||
|
|
||||||
use common\helpers\TransliteratorHelper;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use backend\modules\document\models\DocumentField;
|
use backend\modules\document\models\DocumentField;
|
||||||
use backend\modules\document\models\DocumentFieldSearch;
|
use backend\modules\document\models\DocumentFieldSearch;
|
||||||
|
@ -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.');
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,16 +3,16 @@
|
|||||||
namespace backend\modules\document\controllers;
|
namespace backend\modules\document\controllers;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use backend\modules\document\models\AccompanyingDocument;
|
use backend\modules\document\models\DocumentTemplate;
|
||||||
use backend\modules\document\models\AccompanyingDocumentSearch;
|
use backend\modules\document\models\DocumentTemplateSearch;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
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}
|
* {@inheritdoc}
|
||||||
@ -30,12 +30,12 @@ class AccompanyingDocumentController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all AccompanyingDocument models.
|
* Lists all DocumentTemplate models.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
$searchModel = new AccompanyingDocumentSearch();
|
$searchModel = new DocumentTemplateSearch();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
return $this->render('index', [
|
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
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws NotFoundHttpException if the model cannot be found
|
* @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.
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function actionCreate()
|
public function actionCreate()
|
||||||
{
|
{
|
||||||
$model = new AccompanyingDocument();
|
$model = new DocumentTemplate();
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id]);
|
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.
|
* If update is successful, the browser will be redirected to the 'view' page.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @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.
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @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.
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return AccompanyingDocument the loaded model
|
* @return DocumentTemplate the loaded model
|
||||||
* @throws NotFoundHttpException if the model cannot be found
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
*/
|
*/
|
||||||
protected function findModel($id)
|
protected function findModel($id)
|
||||||
{
|
{
|
||||||
if (($model = AccompanyingDocument::findOne($id)) !== null) {
|
if (($model = DocumentTemplate::findOne($id)) !== null) {
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
@ -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.');
|
|
||||||
}
|
|
||||||
}
|
|
@ -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.');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace backend\modules\document\models;
|
|
||||||
|
|
||||||
use Yii;
|
|
||||||
|
|
||||||
class AccompanyingDocument extends \common\models\AccompanyingDocument
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace backend\modules\document\models;
|
namespace backend\modules\document\models;
|
||||||
|
|
||||||
use Yii;
|
|
||||||
|
|
||||||
|
|
||||||
class Document extends \common\models\Document
|
class Document extends \common\models\Document
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace backend\modules\document\models;
|
namespace backend\modules\document\models;
|
||||||
|
|
||||||
use Yii;
|
|
||||||
|
|
||||||
|
|
||||||
class DocumentField extends \common\models\DocumentField
|
class DocumentField extends \common\models\DocumentField
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace backend\modules\document\models;
|
|
||||||
|
|
||||||
use Yii;
|
|
||||||
|
|
||||||
class DocumentFieldValue extends \common\models\DocumentFieldValue
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,8 +17,8 @@ class DocumentSearch extends Document
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['id', 'template_id', 'manager_id'], 'integer'],
|
[['id', 'company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'template_id'], 'integer'],
|
||||||
[['title', 'created_at', 'updated_at'], 'safe'],
|
[['title', 'body', 'created_at', 'updated_at'], 'safe'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +59,17 @@ class DocumentSearch extends Document
|
|||||||
// grid filtering conditions
|
// grid filtering conditions
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'id' => $this->id,
|
'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,
|
'created_at' => $this->created_at,
|
||||||
'updated_at' => $this->updated_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;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
8
backend/modules/document/models/DocumentTemplate.php
Normal file
8
backend/modules/document/models/DocumentTemplate.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\document\models;
|
||||||
|
|
||||||
|
class DocumentTemplate extends \common\models\DocumentTemplate
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -4,12 +4,12 @@ namespace backend\modules\document\models;
|
|||||||
|
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ActiveDataProvider;
|
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}
|
* {@inheritdoc}
|
||||||
@ -17,8 +17,8 @@ class TemplateSearch extends Template
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['id', 'document_type'], 'integer'],
|
[['id', 'status'], 'integer'],
|
||||||
[['title', 'document_type', 'created_at', 'updated_at', 'template_file_name'], 'safe'],
|
[['title', 'template_body', 'created_at', 'updated_at'], 'safe'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class TemplateSearch extends Template
|
|||||||
*/
|
*/
|
||||||
public function search($params)
|
public function search($params)
|
||||||
{
|
{
|
||||||
$query = Template::find();
|
$query = DocumentTemplate::find();
|
||||||
|
|
||||||
// add conditions that should always apply here
|
// add conditions that should always apply here
|
||||||
|
|
||||||
@ -59,13 +59,13 @@ class TemplateSearch extends Template
|
|||||||
// grid filtering conditions
|
// grid filtering conditions
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
'status' => $this->status,
|
||||||
'created_at' => $this->created_at,
|
'created_at' => $this->created_at,
|
||||||
'updated_at' => $this->updated_at,
|
'updated_at' => $this->updated_at,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$query->andFilterWhere(['like', 'title', $this->title])
|
$query->andFilterWhere(['like', 'title', $this->title])
|
||||||
->andFilterWhere(['like', 'template_file_name', $this->template_file_name])
|
->andFilterWhere(['like', 'template_body', $this->template_body]);
|
||||||
->andFilterWhere(['like', 'document_type', $this->document_type]);
|
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace backend\modules\document\models;
|
|
||||||
|
|
||||||
|
|
||||||
class Template extends \common\models\Template
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace backend\modules\document\models;
|
|
||||||
|
|
||||||
use Yii;
|
|
||||||
|
|
||||||
|
|
||||||
class TemplateDocumentField extends \common\models\TemplateDocumentField
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -14,6 +14,8 @@ use yii\widgets\ActiveForm;
|
|||||||
|
|
||||||
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'field_template')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@ use yii\helpers\Html;
|
|||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\modules\document\models\DocumentField */
|
/* @var $model backend\modules\document\models\DocumentField */
|
||||||
|
|
||||||
$this->title = 'Создание поля документа';
|
$this->title = 'Создать ноое поле';
|
||||||
$this->params['breadcrumbs'][] = ['label' => 'Document Fields', 'url' => ['index']];
|
$this->params['breadcrumbs'][] = ['label' => 'Document Fields', 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
|
@ -12,10 +12,8 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
?>
|
?>
|
||||||
<div class="document-field-index">
|
<div class="document-field-index">
|
||||||
|
|
||||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a('Создать новое поле', ['create'], ['class' => 'btn btn-success']) ?>
|
<?= Html::a('Создать поле', ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?= GridView::widget([
|
<?= GridView::widget([
|
||||||
@ -25,12 +23,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
['class' => 'yii\grid\SerialColumn'],
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
|
||||||
'title',
|
'title',
|
||||||
[
|
'field_template',
|
||||||
'attribute' => 'field_template',
|
|
||||||
'value' => function($model) {
|
|
||||||
return '${' . $model->field_template . '}';
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
['class' => 'yii\grid\ActionColumn'],
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
],
|
],
|
||||||
|
@ -5,7 +5,7 @@ use yii\helpers\Html;
|
|||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\modules\document\models\DocumentField */
|
/* @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' => 'Document Fields', 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
|
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
|
||||||
$this->params['breadcrumbs'][] = 'Update';
|
$this->params['breadcrumbs'][] = 'Update';
|
||||||
|
@ -30,10 +30,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'attributes' => [
|
'attributes' => [
|
||||||
'id',
|
'id',
|
||||||
'title',
|
'title',
|
||||||
[
|
'field_template',
|
||||||
'attribute' => 'field_template',
|
|
||||||
'value' => '${' . $model->field_template . '}',
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
102
backend/modules/document/views/document-template/_form.php
Normal file
102
backend/modules/document/views/document-template/_form.php
Normal 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>
|
||||||
|
|
@ -4,11 +4,11 @@ use yii\helpers\Html;
|
|||||||
use yii\widgets\ActiveForm;
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\modules\document\models\TemplateSearch */
|
/* @var $model backend\modules\document\models\DocumentTemplateSearch */
|
||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="template-search">
|
<div class="document-template-search">
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin([
|
<?php $form = ActiveForm::begin([
|
||||||
'action' => ['index'],
|
'action' => ['index'],
|
||||||
@ -19,9 +19,13 @@ use yii\widgets\ActiveForm;
|
|||||||
|
|
||||||
<?= $form->field($model, 'title') ?>
|
<?= $form->field($model, 'title') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'template_body') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'status') ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'created_at') ?>
|
<?= $form->field($model, 'created_at') ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'updated_at') ?>
|
<?php // echo $form->field($model, 'updated_at') ?>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
18
backend/modules/document/views/document-template/create.php
Normal file
18
backend/modules/document/views/document-template/create.php
Normal 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>
|
@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use common\helpers\TemplateDocumentTypeHelper;
|
use common\helpers\StatusHelper;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\modules\document\models\TemplateSearch */
|
/* @var $searchModel backend\modules\document\models\DocumentTemplateSearch */
|
||||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
$this->title = 'Шаблоны';
|
$this->title = 'Шаблоны документов';
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
<div class="template-index">
|
<div class="document-template-index">
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a('Создать шаблон', ['create'], ['class' => 'btn btn-success']) ?>
|
<?= Html::a('Создать шаблон', ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
@ -24,22 +24,20 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
['class' => 'yii\grid\SerialColumn'],
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
|
||||||
'title',
|
'title',
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
[
|
[
|
||||||
'attribute' => 'document_type',
|
'attribute' => 'status',
|
||||||
// 'format' => 'raw',
|
'format' => 'raw',
|
||||||
'filter' => TemplateDocumentTypeHelper::getDocumentTypeList(),
|
'filter' => StatusHelper::statusList(),
|
||||||
'value' => function($model){
|
'value' => function($model){
|
||||||
return TemplateDocumentTypeHelper::getDocumentType($model->document_type);
|
return StatusHelper::statusLabel($model->status);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
'created_at',
|
||||||
'class' => 'yii\grid\ActionColumn',
|
//'updated_at',
|
||||||
'template' => '{view} {delete}',
|
// 'template_body:ntext',
|
||||||
],
|
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
],
|
],
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
19
backend/modules/document/views/document-template/update.php
Normal file
19
backend/modules/document/views/document-template/update.php
Normal 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>
|
@ -1,18 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use yii\helpers\ArrayHelper;
|
use common\helpers\StatusHelper;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\DetailView;
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\modules\document\models\TemplateDocumentField */
|
/* @var $model backend\modules\document\models\DocumentTemplate */
|
||||||
|
|
||||||
$this->title = 'Поле шаблона';
|
$this->title = $model->title;
|
||||||
$this->params['breadcrumbs'][] = ['label' => 'Template Document Fields', 'url' => ['index']];
|
$this->params['breadcrumbs'][] = ['label' => 'Document Templates', 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
\yii\web\YiiAsset::register($this);
|
\yii\web\YiiAsset::register($this);
|
||||||
?>
|
?>
|
||||||
<div class="template-document-field-view">
|
<div class="document-template-view">
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
@ -30,13 +30,24 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'id',
|
'id',
|
||||||
|
'title',
|
||||||
[
|
[
|
||||||
'attribute' => 'template_id',
|
'attribute' => 'status',
|
||||||
'value' => ArrayHelper::getValue($model, 'template.title'),
|
'format' => 'raw',
|
||||||
|
'value' => StatusHelper::statusLabel($model->status),
|
||||||
|
],
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
[
|
||||||
|
'attribute' => 'template_body',
|
||||||
|
'format' => 'raw'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'field_id',
|
'attribute' => 'Переменные в шаблоне',
|
||||||
'value' => ArrayHelper::getValue($model, 'field.title'),
|
'value' => function($model){
|
||||||
|
preg_match_all('/(\${\w+})/', $model->template_body,$out);
|
||||||
|
return implode(",", $out[0]);
|
||||||
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?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 backend\modules\employee\models\Manager;
|
||||||
use kartik\select2\Select2;
|
use kartik\select2\Select2;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
@ -15,28 +16,59 @@ use yii\widgets\ActiveForm;
|
|||||||
|
|
||||||
<?php $form = ActiveForm::begin(); ?>
|
<?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'])
|
'data' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
|
||||||
->joinWith('userCard')
|
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||||
->indexBy('manager.id')->column(),
|
|
||||||
'options' => ['placeholder' => 'Выберите менеджера','class' => 'form-control'],
|
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'allowClear' => true
|
'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, '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'])
|
'data' => DocumentTemplate::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||||
->indexBy('id')->column(),
|
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||||
'options' => ['placeholder' => 'Выберите шаблон','class' => 'form-control'],
|
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'allowClear' => true
|
'allowClear' => true
|
||||||
],
|
],
|
||||||
]) ?>
|
]
|
||||||
|
); ?>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||||
|
@ -17,15 +17,23 @@ use yii\widgets\ActiveForm;
|
|||||||
|
|
||||||
<?= $form->field($model, 'id') ?>
|
<?= $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">
|
<div class="form-group">
|
||||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||||
|
48
backend/modules/document/views/document/download.php
Normal file
48
backend/modules/document/views/document/download.php
Normal 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>
|
@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use backend\modules\document\models\Document;
|
use backend\modules\company\models\Company;
|
||||||
use backend\modules\document\models\Template;
|
use backend\modules\employee\models\Manager;
|
||||||
use kartik\select2\Select2;
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
|
||||||
@ -25,64 +24,47 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'columns' => [
|
'columns' => [
|
||||||
['class' => 'yii\grid\SerialColumn'],
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
|
||||||
|
'title',
|
||||||
|
// 'body:ntext',
|
||||||
[
|
[
|
||||||
'attribute' => 'title',
|
'attribute' => 'company_id',
|
||||||
'filter' => Select2::widget([
|
'filter' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
|
||||||
'model' => $searchModel,
|
'value' => 'company.name'
|
||||||
'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',
|
'attribute' => 'contractor_company_id',
|
||||||
'filter' => Select2::widget([
|
'filter' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
|
||||||
'model' => $searchModel,
|
'value' => 'contractorCompany.name'
|
||||||
'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',
|
'attribute' => 'manager_id',
|
||||||
'filter' => Select2::widget([
|
'filter' => Manager::find()->select(['fio', 'manager.id'])
|
||||||
'model' => $searchModel,
|
->joinWith('userCard')->indexBy('manager.id')->column(),
|
||||||
'attribute' => 'manager_id',
|
'value' => 'manager.userCard.fio'
|
||||||
'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',
|
'attribute' => 'contractor_manager_id',
|
||||||
'placeholder' => 'Выберите значение'
|
'filter' => Manager::find()->select(['fio', 'manager.id'])
|
||||||
|
->joinWith('userCard')->indexBy('manager.id')->column(),
|
||||||
|
'value' => 'manager.userCard.fio'
|
||||||
],
|
],
|
||||||
]),
|
//'title',
|
||||||
'value' => 'manager.userCard.fio',
|
//'body:ntext',
|
||||||
],
|
//'created_at',
|
||||||
'created_at',
|
//'updated_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>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@ use yii\helpers\Html;
|
|||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\modules\document\models\Document */
|
/* @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' => 'Documents', 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
|
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
|
||||||
$this->params['breadcrumbs'][] = 'Update';
|
$this->params['breadcrumbs'][] = 'Update';
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use yii\grid\GridView;
|
use common\classes\Debug;
|
||||||
|
use common\models\Document;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\DetailView;
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\modules\document\models\Document */
|
/* @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'][] = ['label' => 'Documents', 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
\yii\web\YiiAsset::register($this);
|
\yii\web\YiiAsset::register($this);
|
||||||
?>
|
?>
|
||||||
<div class="document-view">
|
<div class="document-view">
|
||||||
|
|
||||||
<!-- --><?php // \common\models\Document::getDocumentWitchAndFieldValues(31); die?>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
<?= Html::a('Изменить', ['update', '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], [
|
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
|
||||||
'class' => 'btn btn-danger',
|
'class' => 'btn btn-danger',
|
||||||
'data' => [
|
'data' => [
|
||||||
@ -28,6 +27,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?= DetailView::widget([
|
<?= DetailView::widget([
|
||||||
@ -35,77 +35,30 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'attributes' => [
|
'attributes' => [
|
||||||
'id',
|
'id',
|
||||||
'title',
|
'title',
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
[
|
[
|
||||||
'attribute' => 'template_id',
|
'attribute' => 'company_id',
|
||||||
'value' => ArrayHelper::getValue($model,'template.title'),
|
'value' => ArrayHelper::getValue($model, 'company.name'),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'manager_id',
|
'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>
|
</div>
|
||||||
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -27,12 +27,14 @@
|
|||||||
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/settings/additional-fields'], 'active' => \Yii::$app->controller->id == 'additional-fields'],
|
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/settings/additional-fields'], 'active' => \Yii::$app->controller->id == 'additional-fields'],
|
||||||
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position'],
|
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position'],
|
||||||
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill'],
|
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill'],
|
||||||
['label' => 'Шаблоны резюме', 'icon' => 'file', 'url' => ['/card/resume-template'], 'active' => \Yii::$app->controller->id == 'resume-template']
|
['label' => 'Шаблоны резюме', 'icon' => 'address-card ', 'url' => ['/card/resume-template'], 'active' => \Yii::$app->controller->id == 'resume-template'],
|
||||||
|
['label' => 'Шаблоны документов', 'icon' => 'file', 'url' => ['/document/document-template'], 'active' => \Yii::$app->controller->id == 'document-template'],
|
||||||
|
['label' => 'Поля документов', 'icon' => 'file-text', 'url' => ['/document/document-field'], 'active' => \Yii::$app->controller->id == 'document-field'],
|
||||||
],
|
],
|
||||||
'visible' => Yii::$app->user->can('confidential_information')
|
'visible' => Yii::$app->user->can('confidential_information')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => 'Профили', 'icon' => 'address-book-o', 'url' => '#',
|
'label' => 'Профили', 'icon' => 'address-book-o', 'url' => '#', //'active' => \Yii::$app->controller->id == 'user-card',
|
||||||
'items' => $menuItems,
|
'items' => $menuItems,
|
||||||
'visible' => Yii::$app->user->can('confidential_information')
|
'visible' => Yii::$app->user->can('confidential_information')
|
||||||
],
|
],
|
||||||
@ -44,23 +46,7 @@
|
|||||||
],
|
],
|
||||||
'visible' => Yii::$app->user->can('confidential_information')
|
'visible' => Yii::$app->user->can('confidential_information')
|
||||||
],
|
],
|
||||||
[
|
['label' => 'Документы', 'icon' => 'archive', 'url' => ['/document/document'], 'active' => \Yii::$app->controller->id == 'document', 'visible' => Yii::$app->user->can('confidential_information')],
|
||||||
'label' => 'Документы', 'icon' => 'archive', 'url' => '#',
|
|
||||||
'items' => [
|
|
||||||
['label' => 'Документы', 'icon' => 'file-text', 'url' => ['/document/document'], 'active' => \Yii::$app->controller->id == 'document'],
|
|
||||||
['label' => 'Шаблоны', 'icon' => 'file', 'url' => ['/document/template'], 'active' => \Yii::$app->controller->id == 'template'],
|
|
||||||
['label' => 'Поля документов', 'icon' => 'file-text-o', 'url' => ['/document/document-field'], 'active' => \Yii::$app->controller->id == 'document-field'],
|
|
||||||
[
|
|
||||||
'label' => 'Сохранённые значения', 'icon' => 'info-circle', 'url' => '#',
|
|
||||||
'items' => [
|
|
||||||
['label' => 'Поля в шаблоне', 'icon' => 'file-text-o', 'url' => ['/document/template-document-field'], 'active' => \Yii::$app->controller->id == 'template-document-field'],
|
|
||||||
['label' => 'Значения полей', 'icon' => 'bars', 'url' => ['/document/document-field-value'], 'active' => \Yii::$app->controller->id == 'document-field-value'],
|
|
||||||
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'visible' => Yii::$app->user->can('confidential_information')
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'],
|
'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'],
|
||||||
'items' => $projectItems,
|
'items' => $projectItems,
|
||||||
@ -74,7 +60,7 @@
|
|||||||
],
|
],
|
||||||
'visible' => Yii::$app->user->can('confidential_information')
|
'visible' => Yii::$app->user->can('confidential_information')
|
||||||
],
|
],
|
||||||
['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company', 'visible' => Yii::$app->user->can('confidential_information')],
|
['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company', ], // 'visible' => Yii::$app->user->can('confidential_information')
|
||||||
[
|
[
|
||||||
'label' => 'Hh.ru', 'icon' => 'user-circle', 'url' => '#',
|
'label' => 'Hh.ru', 'icon' => 'user-circle', 'url' => '#',
|
||||||
'items' => [
|
'items' => [
|
||||||
|
@ -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']);
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,28 +2,34 @@
|
|||||||
|
|
||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
|
||||||
use yii\behaviors\TimestampBehavior;
|
use yii\behaviors\TimestampBehavior;
|
||||||
use yii\db\ActiveQuery;
|
|
||||||
use yii\db\Expression;
|
use yii\db\Expression;
|
||||||
use yii\db\StaleObjectException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "document".
|
* This is the model class for table "document".
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
|
* @property int $company_id
|
||||||
|
* @property int $contractor_company_id
|
||||||
|
* @property int $manager_id
|
||||||
|
* @property int $contractor_manager_id
|
||||||
|
* @property int $template_id
|
||||||
* @property string $title
|
* @property string $title
|
||||||
|
* @property string $body
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
* @property int $template_id
|
|
||||||
* @property int $manager_id
|
|
||||||
*
|
*
|
||||||
|
* @property Company $company
|
||||||
|
* @property Company $contractorCompany
|
||||||
|
* @property Manager $contractorManager
|
||||||
|
* @property DocumentTemplate $template
|
||||||
* @property Manager $manager
|
* @property Manager $manager
|
||||||
* @property Template $template
|
|
||||||
* @property DocumentFieldValue[] $documentFieldValues
|
|
||||||
*/
|
*/
|
||||||
class Document extends \yii\db\ActiveRecord
|
class Document extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
|
const SCENARIO_UPDATE_DOCUMENT_BODY = 'update_document_body';
|
||||||
|
const SCENARIO_DOWNLOAD_DOCUMENT = 'download_document';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -44,31 +50,30 @@ class Document extends \yii\db\ActiveRecord
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Throwable
|
|
||||||
* @throws StaleObjectException
|
|
||||||
*/
|
|
||||||
public function beforeDelete()
|
|
||||||
{
|
|
||||||
foreach ($this->documentFieldValues as $documentFieldValue){
|
|
||||||
$documentFieldValue->delete();
|
|
||||||
}
|
|
||||||
return parent::beforeDelete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
[['company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'title', 'template_id'], 'required'],
|
||||||
|
[['company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'template_id'], 'integer'],
|
||||||
|
[['body'], 'string'],
|
||||||
[['created_at', 'updated_at'], 'safe'],
|
[['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],
|
[['title'], 'string', 'max' => 255],
|
||||||
|
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::className(), 'targetAttribute' => ['company_id' => 'id']],
|
||||||
|
[['contractor_company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::className(), 'targetAttribute' => ['contractor_company_id' => 'id']],
|
||||||
|
[['contractor_manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['contractor_manager_id' => 'id']],
|
||||||
|
[['template_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocumentTemplate::className(), 'targetAttribute' => ['template_id' => 'id']],
|
||||||
[['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
|
[['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
|
||||||
[['template_id'], 'exist', 'skipOnError' => true, 'targetClass' => Template::className(), 'targetAttribute' => ['template_id' => 'id']],
|
['body', 'required', 'on' => self::SCENARIO_UPDATE_DOCUMENT_BODY],
|
||||||
|
['body', function ($attribute, $params) {
|
||||||
|
preg_match_all('/(\${\w+})/', $this->$attribute,$out);
|
||||||
|
if (!empty($out[0])) {
|
||||||
|
$this->addError('body', 'В теле документа все переменные должны бвть заменены!');
|
||||||
|
}
|
||||||
|
}, 'on' => self::SCENARIO_DOWNLOAD_DOCUMENT
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,35 +84,55 @@ class Document extends \yii\db\ActiveRecord
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => 'ID',
|
'id' => 'ID',
|
||||||
'title' => 'Название',
|
'company_id' => 'Компания',
|
||||||
'created_at' => 'Дата создания',
|
'contractor_company_id' => 'Компания контрагент',
|
||||||
'updated_at' => 'Дата обновления',
|
|
||||||
'template_id' => 'Шаблон',
|
|
||||||
'manager_id' => 'Менеджер',
|
'manager_id' => 'Менеджер',
|
||||||
|
'contractor_manager_id' => 'Менеджер контрагент',
|
||||||
|
'template_id' => 'Шаблон документа',
|
||||||
|
'title' => 'Название',
|
||||||
|
'body' => 'Тело документа',
|
||||||
|
'created_at' => 'Created At',
|
||||||
|
'updated_at' => 'Updated At',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ActiveQuery
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getTemplate()
|
||||||
|
{
|
||||||
|
return $this->hasOne(DocumentTemplate::className(), ['id' => 'template_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getCompany()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Company::className(), ['id' => 'company_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getContractorCompany()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Company::className(), ['id' => 'contractor_company_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getContractorManager()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Manager::className(), ['id' => 'contractor_manager_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
*/
|
*/
|
||||||
public function getManager()
|
public function getManager()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Manager::className(), ['id' => 'manager_id']);
|
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']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use common\helpers\TransliteratorHelper;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
@ -12,9 +11,6 @@ use yii\helpers\ArrayHelper;
|
|||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $title
|
* @property string $title
|
||||||
* @property string $field_template
|
* @property string $field_template
|
||||||
*
|
|
||||||
* @property DocumentFieldValue[] $documentFieldValues
|
|
||||||
* @property TemplateDocumentField[] $templateDocumentFields
|
|
||||||
*/
|
*/
|
||||||
class DocumentField extends \yii\db\ActiveRecord
|
class DocumentField extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
@ -36,12 +32,6 @@ class DocumentField extends \yii\db\ActiveRecord
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeSave($insert)
|
|
||||||
{
|
|
||||||
$this->field_template = TransliteratorHelper::transliterate($this->title);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -54,27 +44,8 @@ class DocumentField extends \yii\db\ActiveRecord
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static function getTitleFieldTemplateArr(): array
|
||||||
* @return \yii\db\ActiveQuery
|
|
||||||
*/
|
|
||||||
public function getDocumentFieldValues()
|
|
||||||
{
|
{
|
||||||
return $this->hasMany(DocumentFieldValue::className(), ['field_id' => 'id']);
|
return ArrayHelper::map(self::find()->all(), 'title', 'field_template');
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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']);
|
|
||||||
}
|
|
||||||
}
|
|
69
common/models/DocumentTemplate.php
Normal file
69
common/models/DocumentTemplate.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\behaviors\TimestampBehavior;
|
||||||
|
use yii\db\Expression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "document_template".
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property string $title
|
||||||
|
* @property string $template_body
|
||||||
|
* @property int $status
|
||||||
|
* @property string $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
*/
|
||||||
|
class DocumentTemplate extends \yii\db\ActiveRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'document_template';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function behaviors()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'class' => TimestampBehavior::class,
|
||||||
|
'createdAtAttribute' => 'created_at',
|
||||||
|
'updatedAtAttribute' => 'updated_at',
|
||||||
|
'value' => new Expression('NOW()'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['status', 'title', 'template_body'], 'required'],
|
||||||
|
[['template_body'], 'string'],
|
||||||
|
[['status'], 'integer'],
|
||||||
|
[['created_at', 'updated_at'], 'safe'],
|
||||||
|
[['title'], 'string', 'max' => 255],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
|
'title' => 'Название',
|
||||||
|
'template_body' => 'Тело шаблона',
|
||||||
|
'status' => 'Статус',
|
||||||
|
'created_at' => 'Created At',
|
||||||
|
'updated_at' => 'Updated At',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -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');
|
|
||||||
}
|
|
||||||
}
|
|
@ -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']);
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,6 +3,9 @@
|
|||||||
namespace common\services;
|
namespace common\services;
|
||||||
|
|
||||||
use common\models\Document;
|
use common\models\Document;
|
||||||
|
use common\models\DocumentTemplate;
|
||||||
|
use DateTime;
|
||||||
|
use kartik\mpdf\Pdf;
|
||||||
|
|
||||||
class DocumentService
|
class DocumentService
|
||||||
{
|
{
|
||||||
@ -25,4 +28,94 @@ class DocumentService
|
|||||||
->asArray()->all();
|
->asArray()->all();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getDocumentNumber(): string
|
||||||
|
{
|
||||||
|
$documents = Document::find()->where(['DATE(`created_at`)' => date('Y-m-d')])->orderBy('id DESC')->all();
|
||||||
|
$date = new DateTime();
|
||||||
|
|
||||||
|
foreach ($documents as $document) {
|
||||||
|
preg_match_all('/\b\d{2}\.\d{2}\.\d{4}\/\d{3}\b/', $document->body,$out);
|
||||||
|
|
||||||
|
if (!empty($out[0])) {
|
||||||
|
$num = substr($out[0][0], -3);
|
||||||
|
$num++;
|
||||||
|
$num = str_pad($num, 3, "0", STR_PAD_LEFT);
|
||||||
|
|
||||||
|
return $date->format('d.m.Y') . '/' . $num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $date->format('d.m.Y') . '/001';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function downloadPdf($id)
|
||||||
|
{
|
||||||
|
$model = Document::findOne($id);
|
||||||
|
|
||||||
|
$pdf = new Pdf(); // or new Pdf();
|
||||||
|
$mpdf = $pdf->api; // fetches mpdf api
|
||||||
|
$mpdf->SetFooter('{PAGENO}');
|
||||||
|
$mpdf->WriteHtml($model->body); // call mpdf write html
|
||||||
|
echo $mpdf->Output("{$model->title}", 'D'); // call the mpdf api output as needed
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function downloadDocx($id)
|
||||||
|
{
|
||||||
|
$model = Document::findOne($id);
|
||||||
|
|
||||||
|
$pw = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
|
||||||
|
// (B) ADD HTML CONTENT
|
||||||
|
$section = $pw->addSection();
|
||||||
|
$documentText = str_replace(array('<br/>', '<br>', '</br>'), ' ', $model->body);
|
||||||
|
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $documentText, false, false);
|
||||||
|
|
||||||
|
// (C) SAVE TO DOCX ON SERVER
|
||||||
|
// $pw->save("convert.docx", "Word2007");
|
||||||
|
|
||||||
|
// (D) OR FORCE DOWNLOAD
|
||||||
|
header("Content-Type: application/octet-stream");
|
||||||
|
header("Content-Disposition: attachment;filename=\"$model->title.docx\"");
|
||||||
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($pw, "Word2007");
|
||||||
|
$objWriter->save("php://output");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function generateDocumentBody(Document $model)
|
||||||
|
{
|
||||||
|
$templateModel = DocumentTemplate::findOne($model->template_id);
|
||||||
|
preg_match_all('/(\${\w+})/', $templateModel->template_body,$out);
|
||||||
|
|
||||||
|
$document = $templateModel->template_body;;
|
||||||
|
foreach ($out[0] as $field) {
|
||||||
|
if (str_contains($document, $field)) {
|
||||||
|
switch ($field)
|
||||||
|
{
|
||||||
|
case '${contract_number}':
|
||||||
|
$fieldValue = DocumentService::getDocumentNumber();
|
||||||
|
break;
|
||||||
|
case '${title}':
|
||||||
|
$fieldValue = $model->title;
|
||||||
|
break;
|
||||||
|
case '${company}':
|
||||||
|
$fieldValue = $model->company->name;
|
||||||
|
break;
|
||||||
|
case '${manager}':
|
||||||
|
$fieldValue = $model->manager->userCard->fio;
|
||||||
|
break;
|
||||||
|
case '${contractor_company}':
|
||||||
|
$fieldValue = $model->contractorCompany->name;
|
||||||
|
break;
|
||||||
|
case '${contractor_manager}':
|
||||||
|
$fieldValue = $model->contractorManager->userCard->fio;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$fieldValue = $field;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$document = str_replace($field, $fieldValue, $document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$model->body = $document;
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
<?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');
|
||||||
|
$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('{{%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;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the creation of table `{{%document_template}}`.
|
||||||
|
*/
|
||||||
|
class m221108_135514_create_document_template_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->createTable('{{%document_template}}', [
|
||||||
|
'id' => $this->primaryKey(),
|
||||||
|
'title' => $this->string(),
|
||||||
|
'template_body' => $this->text(),
|
||||||
|
'status' => $this->integer(),
|
||||||
|
'created_at' => $this->dateTime(),
|
||||||
|
'updated_at' => $this->dateTime(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropTable('{{%document_template}}');
|
||||||
|
}
|
||||||
|
}
|
42
console/migrations/m221108_135939_create_document_table.php
Normal file
42
console/migrations/m221108_135939_create_document_table.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the creation of table `{{%document}}`.
|
||||||
|
*/
|
||||||
|
class m221108_135939_create_document_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->createTable('{{%document}}', [
|
||||||
|
'id' => $this->primaryKey(),
|
||||||
|
'company_id' => $this->integer(11)->notNull(),
|
||||||
|
'contractor_company_id' => $this->integer(11)->notNull(),
|
||||||
|
'manager_id' => $this->integer(11)->notNull(),
|
||||||
|
'contractor_manager_id' => $this->integer(11)->notNull(),
|
||||||
|
'template_id' => $this->integer(11)->notNull(),
|
||||||
|
'title' => $this->string(),
|
||||||
|
'body' => $this->text(),
|
||||||
|
'created_at' => $this->dateTime(),
|
||||||
|
'updated_at' => $this->dateTime(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->addForeignKey('company_document', 'document', 'company_id', 'company', 'id');
|
||||||
|
$this->addForeignKey('contractor_company_document', 'document', 'contractor_company_id', 'company', 'id');
|
||||||
|
$this->addForeignKey('manager_document', 'document', 'manager_id','manager', 'id');
|
||||||
|
$this->addForeignKey('contractor_manager_document', 'document', 'contractor_manager_id','manager', 'id');
|
||||||
|
$this->addForeignKey('document_template_document', 'document', 'template_id','document_template', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropTable('{{%document}}');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use common\models\DocumentField;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class m221115_094557_add_update_default_and_add_new_fields_in_document_field_table
|
||||||
|
*/
|
||||||
|
class m221115_094557_update_default_and_add_new_fields_in_document_field_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$documentFields = DocumentField::find()->all();
|
||||||
|
foreach ($documentFields as $documentField) {
|
||||||
|
$documentField->field_template = '${' . $documentField->field_template . '}';
|
||||||
|
$documentField->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
Yii::$app->db->createCommand()->batchInsert('document_field', [ 'title', 'field_template'],
|
||||||
|
[
|
||||||
|
['№ договора', '${contract_number}'],
|
||||||
|
['Название', '${title}'],
|
||||||
|
['Компания', '${company}'],
|
||||||
|
['Представитель', '${manager}'],
|
||||||
|
['Компания контрагент', '${contractor_company}'],
|
||||||
|
['Представитель контрагента', '${contractor_manager}']
|
||||||
|
])->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
Yii::$app->db->createCommand()->delete('document_field',
|
||||||
|
[
|
||||||
|
'in', 'title', [
|
||||||
|
'№ договора',
|
||||||
|
'Название',
|
||||||
|
'Компания',
|
||||||
|
'Представитель',
|
||||||
|
'Компания контрагент',
|
||||||
|
'Представитель контрагента',
|
||||||
|
]
|
||||||
|
])->execute();
|
||||||
|
|
||||||
|
$documentFields = DocumentField::find()->all();
|
||||||
|
foreach ($documentFields as $documentField) {
|
||||||
|
$documentField->field_template = str_replace(['${', '}'], '', $documentField->field_template);
|
||||||
|
$documentField->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use up()/down() to run migration code without a transaction.
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m221115_094557_add_update_default_andaddnewfieldsin_document_field_table cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
3412
frontend-access.log
3412
frontend-access.log
File diff suppressed because it is too large
Load Diff
@ -15633,3 +15633,29 @@ Stack trace:
|
|||||||
2022/10/19 15:27:04 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/profile?id=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
2022/10/19 15:27:04 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/profile?id=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
2022/10/19 15:27:11 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/profile/get-main-data?user_id=10 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
2022/10/19 15:27:11 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/profile/get-main-data?user_id=10 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
2022/10/19 15:27:14 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/profile/profile-with-report-permission?id=14 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
2022/10/19 15:27:14 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/profile/profile-with-report-permission?id=14 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/11/10 15:04:34 [error] 916#916: *388 FastCGI sent in stderr: "PHP message: An Error occurred while handling another error:
|
||||||
|
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/guild/vendor/mpdf/mpdf/src/Mpdf.php on line 9619. in /var/www/guild/vendor/yiisoft/yii2/web/Response.php:373
|
||||||
|
Stack trace:
|
||||||
|
#0 /var/www/guild/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
|
||||||
|
#1 /var/www/guild/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
|
||||||
|
#2 /var/www/guild/vendor/yiisoft/yii2/base/ErrorHandler.php(135): yii\web\ErrorHandler->renderException()
|
||||||
|
#3 [internal function]: yii\base\ErrorHandler->handleException()
|
||||||
|
#4 {main}
|
||||||
|
Previous exception:
|
||||||
|
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/guild/vendor/mpdf/mpdf/src/Mpdf.php on line 9619. in /var/www/guild/vendor/yiisoft/yii2/web/Response.php:373
|
||||||
|
Stack trace:
|
||||||
|
#0 /var/www/guild/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
|
||||||
|
#1 /var/www/guild/vendor/yiisoft/yii2/base/Application.php(398): yii\web\Response->send()" while reading upstream, client: 127.0.0.1, server: backend.guild.loc, request: "GET /document/document/download-pdf?id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "backend.guild.loc", referrer: "http://backend.guild.loc/document/document/download?id=3"
|
||||||
|
2022/11/10 15:04:44 [error] 916#916: *388 FastCGI sent in stderr: "PHP message: An Error occurred while handling another error:
|
||||||
|
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/guild/vendor/mpdf/mpdf/src/Mpdf.php on line 9619. in /var/www/guild/vendor/yiisoft/yii2/web/Response.php:373
|
||||||
|
Stack trace:
|
||||||
|
#0 /var/www/guild/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
|
||||||
|
#1 /var/www/guild/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
|
||||||
|
#2 /var/www/guild/vendor/yiisoft/yii2/base/ErrorHandler.php(135): yii\web\ErrorHandler->renderException()
|
||||||
|
#3 [internal function]: yii\base\ErrorHandler->handleException()
|
||||||
|
#4 {main}
|
||||||
|
Previous exception:
|
||||||
|
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/guild/vendor/mpdf/mpdf/src/Mpdf.php on line 9619. in /var/www/guild/vendor/yiisoft/yii2/web/Response.php:373
|
||||||
|
Stack trace:
|
||||||
|
#0 /var/www/guild/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
|
||||||
|
#1 /var/www/guild/vendor/yiisoft/yii2/base/Application.php(398): yii\web\Response->send()" while reading upstream, client: 127.0.0.1, server: backend.guild.loc, request: "GET /document/document/download-pdf?id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "backend.guild.loc", referrer: "http://backend.guild.loc/document/document/download?id=3"
|
||||||
|
Loading…
Reference in New Issue
Block a user