drop unnecessary tables and module

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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