From 09a129a74c85b97a1e4390157fdf8317115e9564 Mon Sep 17 00:00:00 2001 From: fomichev Date: Tue, 11 Feb 2025 10:05:35 +0300 Subject: [PATCH] =?utf8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?utf8?q?=20CRUD=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0?= =?utf8?q?=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/composer.json | 5 +- erp24/controllers/WikiCategoryController.php | 152 ++++++++++++++ erp24/controllers/WikiController.php | 167 +++++++++++++++ .../m250210_120558_create_wiki_tables.php | 101 +++++++++ erp24/records/WikiArticle.php | 102 +++++++++ erp24/records/WikiArticleSearch.php | 76 +++++++ erp24/records/WikiCategory.php | 124 +++++++++++ erp24/views/wiki-category/_form.php | 54 +++++ erp24/views/wiki-category/create.php | 20 ++ erp24/views/wiki-category/index.php | 55 +++++ erp24/views/wiki-category/update.php | 21 ++ erp24/views/wiki-category/view.php | 51 +++++ erp24/views/wiki/_form.php | 60 ++++++ erp24/views/wiki/_search.php | 45 ++++ erp24/views/wiki/create.php | 20 ++ erp24/views/wiki/index.php | 193 ++++++++++++++++++ erp24/views/wiki/update.php | 21 ++ erp24/views/wiki/view.php | 71 +++++++ 18 files changed, 1336 insertions(+), 2 deletions(-) create mode 100644 erp24/controllers/WikiCategoryController.php create mode 100644 erp24/controllers/WikiController.php create mode 100644 erp24/migrations/m250210_120558_create_wiki_tables.php create mode 100644 erp24/records/WikiArticle.php create mode 100644 erp24/records/WikiArticleSearch.php create mode 100644 erp24/records/WikiCategory.php create mode 100644 erp24/views/wiki-category/_form.php create mode 100644 erp24/views/wiki-category/create.php create mode 100644 erp24/views/wiki-category/index.php create mode 100644 erp24/views/wiki-category/update.php create mode 100644 erp24/views/wiki-category/view.php create mode 100644 erp24/views/wiki/_form.php create mode 100644 erp24/views/wiki/_search.php create mode 100644 erp24/views/wiki/create.php create mode 100644 erp24/views/wiki/index.php create mode 100644 erp24/views/wiki/update.php create mode 100644 erp24/views/wiki/view.php diff --git a/erp24/composer.json b/erp24/composer.json index ec2445cc..31b7b4c2 100644 --- a/erp24/composer.json +++ b/erp24/composer.json @@ -38,7 +38,8 @@ "enqueue/amqp-lib": "^0.10.19", "vlucas/phpdotenv": "^5.6", "softark/yii2-dual-listbox": "^1.0", - "kartik-v/yii2-widget-depdrop": "dev-master" + "kartik-v/yii2-widget-depdrop": "dev-master", + "sangroya/yii2-ckeditor5": "*" }, "require-dev": { "yiisoft/yii2-debug": "~2.1.0", @@ -61,7 +62,7 @@ "squizlabs/php_codesniffer": "@stable" }, "autoload": { - "psr-4": { "OpenAPI\\Client\\" : "lib/yandex_market_api/" } + "psr-4": { "yii_app\\": "", "OpenAPI\\Client\\" : "lib/yandex_market_api/" } }, "config": { "allow-plugins": { diff --git a/erp24/controllers/WikiCategoryController.php b/erp24/controllers/WikiCategoryController.php new file mode 100644 index 00000000..3adffe63 --- /dev/null +++ b/erp24/controllers/WikiCategoryController.php @@ -0,0 +1,152 @@ + [ + 'class' => VerbFilter::class, + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ] + ); + } + + /** + * Lists all WikiCategory models. + * + * @return string + */ + public function actionIndex() + { + $dataProvider = new ActiveDataProvider([ + 'query' => WikiCategory::find(), + /* + 'pagination' => [ + 'pageSize' => 50 + ], + 'sort' => [ + 'defaultOrder' => [ + 'id' => SORT_DESC, + ] + ], + */ + ]); + + return $this->render('index', [ + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single WikiCategory model. + * @param int $id ID категории + * @return string + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new WikiCategory model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return string|\yii\web\Response + */ + public function actionCreate() + { + $model = new WikiCategory(); + + if ($this->request->isPost) { + if ($model->load($this->request->post())) { + if (!$model->validate()) { + Yii::error('Validation errors: ' . json_encode($model->errors), 'wiki'); + } + if ($model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + Yii::error('Save failed: ' . json_encode($model->errors), 'wiki'); + } + } + } else { + $model->loadDefaultValues(); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing WikiCategory model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param int $id ID категории + * @return string|\yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing WikiCategory model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param int $id ID категории + * @return \yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the WikiCategory model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param int $id ID категории + * @return WikiCategory the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = WikiCategory::findOne(['id' => $id])) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/erp24/controllers/WikiController.php b/erp24/controllers/WikiController.php new file mode 100644 index 00000000..e48902cb --- /dev/null +++ b/erp24/controllers/WikiController.php @@ -0,0 +1,167 @@ + [ + 'class' => VerbFilter::class, + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ] + ); + } + + + /** + * Lists all WikiArticle models. + * + * @return string + */ + public function actionIndex() + { + $searchModel = new WikiArticleSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + $categories = WikiCategory::find()->all(); + $tree = $this->buildTree($categories); + + return $this->render('index', [ + 'tree' => $tree, + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + private function buildTree($categories, $parentId = null) + { + $tree = []; + foreach ($categories as $category) { + if ($category->parent_id == $parentId) { + $tree[] = [ + 'category' => $category, + 'articles' => WikiArticle::find()->where(['category_id' => $category->id])->all(), + 'children' => $this->buildTree($categories, $category->id), + ]; + } + } + return $tree; + } + + /** + * Displays a single WikiArticle model. + * @param int $id ID статьи + * @return string + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($parent_cat_slug, $article_slug) + { + $category = WikiCategory::findOne(['slug' => $parent_cat_slug]); + if (!$category) { + throw new NotFoundHttpException('Category not found.'); + } + + $model = WikiArticle::findOne(['category_id' => $category->id, 'slug' => $article_slug]); + if (!$model) { + throw new NotFoundHttpException('Article not found.'); + } + + return $this->render('view', ['model' => $model]); + } + + /** + * Creates a new WikiArticle model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return string|\yii\web\Response + */ + public function actionCreate() + { + $model = new WikiArticle(); + + if ($this->request->isPost) { + if ($model->load($this->request->post()) && $model->save()) { + // Получаем slug категории и slug статьи + $categorySlug = $model->category->slug; // Slug категории из связанной модели + $articleSlug = $model->slug; // Slug созданной статьи + + // Перенаправляем на страницу просмотра с правильными параметрами + return $this->redirect(['view', 'parent_cat_slug' => $categorySlug, 'article_slug' => $articleSlug]); + } + } else { + $model->loadDefaultValues(); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing WikiArticle model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param int $id ID статьи + * @return string|\yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing WikiArticle model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param int $id ID статьи + * @return \yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + WikiArticle::findOne($id)?->delete(); + return $this->redirect(['index']); + } + + /** + * Finds the WikiArticle model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param int $id ID статьи + * @return WikiArticle the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = WikiArticle::findOne(['id' => $id])) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/erp24/migrations/m250210_120558_create_wiki_tables.php b/erp24/migrations/m250210_120558_create_wiki_tables.php new file mode 100644 index 00000000..ace6de13 --- /dev/null +++ b/erp24/migrations/m250210_120558_create_wiki_tables.php @@ -0,0 +1,101 @@ +db->getTableSchema(self::CATEGORY_TABLE); + $articleSchema = $this->db->getTableSchema(self::ARTICLE_TABLE); + + if (!isset($categorySchema)) { + $this->createTable(self::CATEGORY_TABLE, [ + 'id' => $this->primaryKey()->comment('ID категории'), + 'slug' => $this->string()->notNull()->unique()->comment('ЧПУ'), + 'title' => $this->string()->notNull()->comment('Название'), + 'parent_id' => $this->integer()->null()->comment('Родительская категория'), + 'description' => $this->text()->null()->comment('Описание'), + 'created_at' => $this->string()->notNull()->comment('Дата создания'), + 'created_by' => $this->integer()->notNull()->comment('Кем создано'), + 'updated_at' => $this->string()->null()->comment('Дата обновления'), + 'updated_by' => $this->integer()->null()->comment('Кем обновлено'), + 'allow_group_id' => $this->string()->null()->comment('Разрешенные группы'), + ]); + + $this->addForeignKey( + 'fk-wiki_category-parent_id', + self::CATEGORY_TABLE, + 'parent_id', + self::CATEGORY_TABLE, + 'id', + 'SET NULL' + ); + } + + if (!isset($articleSchema)) { + $this->createTable(self::ARTICLE_TABLE, [ + 'id' => $this->primaryKey()->comment('ID статьи'), + 'slug' => $this->string()->notNull()->unique()->comment('ЧПУ'), + 'title' => $this->string()->notNull()->comment('Название'), + 'category_id' => $this->integer()->notNull()->comment('Категория'), + 'description' => $this->text()->null()->comment('Описание'), + 'content' => $this->text()->notNull()->comment('Контент'), + 'created_at' => $this->string()->notNull()->comment('Дата создания'), + 'created_by' => $this->integer()->notNull()->comment('Кем создано'), + 'updated_at' => $this->string()->null()->comment('Дата обновления'), + 'updated_by' => $this->integer()->null()->comment('Кем обновлено'), + ]); + + $this->addForeignKey( + 'fk-wiki_article-category_id', + self::ARTICLE_TABLE, + 'category_id', + self::CATEGORY_TABLE, + 'id', + 'SET NULL' + ); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $categorySchema = $this->db->getTableSchema(self::CATEGORY_TABLE); + $articleSchema = $this->db->getTableSchema(self::ARTICLE_TABLE); + + if (isset($articleSchema)) { + $this->dropTable(self::ARTICLE_TABLE); + } + + if (isset($categorySchema)) { + $this->dropTable(self::CATEGORY_TABLE); + } + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m250210_120558_create_wiki_tables cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/erp24/records/WikiArticle.php b/erp24/records/WikiArticle.php new file mode 100644 index 00000000..14fb9c99 --- /dev/null +++ b/erp24/records/WikiArticle.php @@ -0,0 +1,102 @@ + TimestampBehavior::class, + 'value' => function () { + return date('Y-m-d H:i:s'); + }, + ], + BlameableBehavior::class, + ]; + } + + public function beforeValidate() + { + if ($this->isNewRecord && !$this->slug) { + $this->slug = Inflector::slug($this->title); + } + return parent::beforeValidate(); + } + + /** + * {@inheritdoc} + */ + public function rules() + { + return [ + [[ 'title', 'category_id', 'content' ], 'required'], + [['category_id', 'created_by', 'updated_by'], 'default', 'value' => null], + [['category_id', 'created_by', 'updated_by'], 'integer'], + [['slug', 'created_at', 'created_by'], 'safe'], + [['description', 'content'], 'string'], + [['slug', 'title', 'created_at', 'updated_at'], 'string', 'max' => 255], + [['slug'], 'unique'], + [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => WikiCategory::class, 'targetAttribute' => ['category_id' => 'id']], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID статьи', + 'slug' => 'ЧПУ', + 'title' => 'Название', + 'category_id' => 'Категория', + 'description' => 'Описание', + 'content' => 'Контент', + 'created_at' => 'Дата создания', + 'created_by' => 'Кем создано', + 'updated_at' => 'Дата обновления', + 'updated_by' => 'Кем обновлено', + ]; + } + + /** + * Gets query for [[Category]]. + * + * @return \yii\db\ActiveQuery + */ + public function getCategory() + { + return $this->hasOne(WikiCategory::class, ['id' => 'category_id']); + } +} diff --git a/erp24/records/WikiArticleSearch.php b/erp24/records/WikiArticleSearch.php new file mode 100644 index 00000000..c2642d00 --- /dev/null +++ b/erp24/records/WikiArticleSearch.php @@ -0,0 +1,76 @@ + $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, + 'category_id' => $this->category_id, + 'created_by' => $this->created_by, + 'updated_by' => $this->updated_by, + ]); + + $query->andFilterWhere(['ilike', 'slug', $this->slug]) + ->andFilterWhere(['ilike', 'title', $this->title]) + ->andFilterWhere(['ilike', 'description', $this->description]) + ->andFilterWhere(['ilike', 'content', $this->content]) + ->andFilterWhere(['ilike', 'created_at', $this->created_at]) + ->andFilterWhere(['ilike', 'updated_at', $this->updated_at]); + + return $dataProvider; + } +} diff --git a/erp24/records/WikiCategory.php b/erp24/records/WikiCategory.php new file mode 100644 index 00000000..7601035b --- /dev/null +++ b/erp24/records/WikiCategory.php @@ -0,0 +1,124 @@ + TimestampBehavior::class, + 'value' => function () { + return date('Y-m-d H:i:s'); + }, + ], + BlameableBehavior::class, + ]; + } + + public function beforeValidate() + { + if ($this->isNewRecord && !$this->slug) { + $this->slug = Inflector::slug($this->title); // Автоматическая генерация slug + } + return parent::beforeValidate(); + } + + /** + * {@inheritdoc} + */ + public function rules() + { + return [ + [[ 'title'], 'required'], + [['parent_id', 'created_by', 'updated_by'], 'default', 'value' => null], + [['parent_id', 'created_by', 'updated_by'], 'integer'], + [['created_at', 'updated_at', 'slug', 'created_at', 'created_by'], 'safe'], + [['description'], 'string'], + [['slug', 'title', 'created_at', 'updated_at', 'allow_group_id'], 'string', 'max' => 255], + [['slug'], 'unique'], + [['parent_id'], 'exist', 'skipOnError' => true, 'targetClass' => WikiCategory::class, 'targetAttribute' => ['parent_id' => 'id']], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID категории', + 'slug' => 'ЧПУ', + 'title' => 'Название', + 'parent_id' => 'Родительская категория', + 'description' => 'Описание', + 'created_at' => 'Дата создания', + 'created_by' => 'Кем создано', + 'updated_at' => 'Дата обновления', + 'updated_by' => 'Кем обновлено', + 'allow_group_id' => 'Разрешенные группы', + ]; + } + + /** + * Gets query for [[Parent]]. + * + * @return \yii\db\ActiveQuery + */ + public function getParent() + { + return $this->hasOne(WikiCategory::class, ['id' => 'parent_id']); + } + + /** + * Gets query for [[WikiArticles]]. + * + * @return \yii\db\ActiveQuery + */ + public function getWikiArticles() + { + return $this->hasMany(WikiArticle::class, ['category_id' => 'id']); + } + + /** + * Gets query for [[WikiCategories]]. + * + * @return \yii\db\ActiveQuery + */ + public function getWikiCategories() + { + return $this->hasMany(WikiCategory::class, ['parent_id' => 'id']); + } +} diff --git a/erp24/views/wiki-category/_form.php b/erp24/views/wiki-category/_form.php new file mode 100644 index 00000000..0f9b087c --- /dev/null +++ b/erp24/views/wiki-category/_form.php @@ -0,0 +1,54 @@ +parent_id == $parentId) { + $result[$category->id] = str_repeat('— ', $level) . $category->title; + $result = ArrayHelper::merge( + $result, + getCategoriesWithHierarchy($categories, $category->id, $level + 1) + ); + } + } + return $result; +} + +$categories = WikiCategory::find()->all(); +$categoryList = getCategoriesWithHierarchy($categories); +?> + +
+ + + + field($model, 'slug')->hiddenInput(['maxlength' => true])->label(false) ?> + + field($model, 'title')->textInput(['maxlength' => true]) ?> + + field($model, 'parent_id')->dropDownList( + $categoryList, + ['prompt' => 'Выберите родительскую категорию'] + ) ?> + + field($model, 'description')->textarea(['rows' => 6]) ?> + + field($model, 'allow_group_id')->textInput(['maxlength' => true]) ?> + +
+ 'btn btn-success']) ?> +
+ + + +
diff --git a/erp24/views/wiki-category/create.php b/erp24/views/wiki-category/create.php new file mode 100644 index 00000000..221104d4 --- /dev/null +++ b/erp24/views/wiki-category/create.php @@ -0,0 +1,20 @@ +title = 'Добавление категории документации'; +$this->params['breadcrumbs'][] = ['label' => 'Wiki Categories', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ 'btn btn-primary my-4']) ?> +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/erp24/views/wiki-category/index.php b/erp24/views/wiki-category/index.php new file mode 100644 index 00000000..99a9c5f3 --- /dev/null +++ b/erp24/views/wiki-category/index.php @@ -0,0 +1,55 @@ +title = 'Категории документации (wiki)'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ 'btn btn-success']) ?> +

+ + + $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'slug', + 'title', + [ + 'attribute' => 'parent_id', + 'value' => function ($model) { + return $model->parent ? $model->parent->title : ''; + }, + 'label' => 'Родитель', + ], + 'description:ntext', + //'created_at', + //'created_by', + //'updated_at', + //'updated_by', + //'allow_group_id', + [ + 'class' => ActionColumn::class, + 'urlCreator' => function ($action, WikiCategory $model, $key, $index, $column) { + return Url::toRoute([$action, 'id' => $model->id]); + } + ], + ], + ]); ?> + + +
diff --git a/erp24/views/wiki-category/update.php b/erp24/views/wiki-category/update.php new file mode 100644 index 00000000..6c098720 --- /dev/null +++ b/erp24/views/wiki-category/update.php @@ -0,0 +1,21 @@ +title = 'Редактирование: ' . $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Wiki Categories', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ 'btn btn-primary my-4']) ?> +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/erp24/views/wiki-category/view.php b/erp24/views/wiki-category/view.php new file mode 100644 index 00000000..2797e44b --- /dev/null +++ b/erp24/views/wiki-category/view.php @@ -0,0 +1,51 @@ +title = $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Wiki Categories', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ 'btn btn-primary my-4']) ?> +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Вы точно хотите удалить?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'slug', + 'title', + [ + 'attribute' => 'parent_id', + 'value' => function ($model) { + return $model->parent ? $model->parent->title : ''; + }, + 'label' => 'Родитель', + ], + 'description:ntext', + 'created_at', + 'created_by', + 'updated_at', + 'updated_by', + 'allow_group_id', + ], + ]) ?> + +
diff --git a/erp24/views/wiki/_form.php b/erp24/views/wiki/_form.php new file mode 100644 index 00000000..15ecddf8 --- /dev/null +++ b/erp24/views/wiki/_form.php @@ -0,0 +1,60 @@ +parent_id == $parentId) { + $result[$category->id] = str_repeat('— ', $level) . $category->title; + $result = ArrayHelper::merge( + $result, + getCategoriesWithHierarchy($categories, $category->id, $level + 1) + ); + } + } + return $result; +} + +$categories = WikiCategory::find()->all(); +$categoryList = getCategoriesWithHierarchy($categories); +?> + +
+ + + + field($model, 'slug')->hiddenInput(['maxlength' => true])->label(false) ?> + + field($model, 'title')->textInput(['maxlength' => true]) ?> + + field($model, 'category_id')->dropDownList( + $categoryList, + ['prompt' => 'Выберите родительскую категорию'] + ) ?> + + field($model, 'description')->textarea(['rows' => 6]) ?> + + field($model, 'content')->widget(CKEditor::class, [ + 'options' => ['rows' => 6], + 'uploadUrl' => '/uploads', + ]) ?> + + +
+ 'btn btn-success']) ?> +
+ + + +
diff --git a/erp24/views/wiki/_search.php b/erp24/views/wiki/_search.php new file mode 100644 index 00000000..30a3fef2 --- /dev/null +++ b/erp24/views/wiki/_search.php @@ -0,0 +1,45 @@ + + +
+ + ['index'], + 'method' => 'get', + ]); ?> + + field($model, 'id') ?> + + field($model, 'slug') ?> + + field($model, 'title') ?> + + field($model, 'category_id') ?> + + field($model, 'description') ?> + + field($model, 'content') ?> + + field($model, 'created_at') ?> + + field($model, 'created_by') ?> + + field($model, 'updated_at') ?> + + field($model, 'updated_by') ?> + +
+ 'btn btn-primary']) ?> + 'btn btn-outline-secondary']) ?> +
+ + + +
diff --git a/erp24/views/wiki/create.php b/erp24/views/wiki/create.php new file mode 100644 index 00000000..1bfcff65 --- /dev/null +++ b/erp24/views/wiki/create.php @@ -0,0 +1,20 @@ +title = 'Добавление статьи'; +$this->params['breadcrumbs'][] = ['label' => 'Wiki Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ 'btn btn-primary my-4']) ?> +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/erp24/views/wiki/index.php b/erp24/views/wiki/index.php new file mode 100644 index 00000000..65bc2d1e --- /dev/null +++ b/erp24/views/wiki/index.php @@ -0,0 +1,193 @@ +title = 'Документация'; +$this->params['breadcrumbs'][] = $this->title; +$user = Yii::$app->user->identity; +function renderTree($tree, $level = 0) +{ + if (empty($tree)) { + return ''; + } + + $html = ''; + + return $html; +} + +?> + +
+

title) ?>

+ group_id == 81) : ?> +

+ 'btn btn-success']) ?> + 'btn btn-success']) ?> +

+ + +
+
+ +
+
+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + 'title', + [ + 'attribute' => 'category_id', + 'value' => function ($model) { + return $model->category ? $model->category->title : ''; + }, + 'label' => 'Категория', + ], + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
+
+
+ + + + + + + + diff --git a/erp24/views/wiki/update.php b/erp24/views/wiki/update.php new file mode 100644 index 00000000..8a40a7ba --- /dev/null +++ b/erp24/views/wiki/update.php @@ -0,0 +1,21 @@ +title = 'Редактировать статью: ' . $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Wiki Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ 'btn btn-primary my-4']) ?> +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/erp24/views/wiki/view.php b/erp24/views/wiki/view.php new file mode 100644 index 00000000..844b23b0 --- /dev/null +++ b/erp24/views/wiki/view.php @@ -0,0 +1,71 @@ +title = $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Wiki Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +$user = Yii::$app->user->identity; +$articleUrl = Url::to(['view', 'parent_cat_slug' => $model->category->slug, 'article_slug' => $model->slug], true); +YiiAsset::register($this); +?> + +
+
+

+ title) ?> + +

+ 'btn btn-secondary']) ?> +
+ +
+ Автор: created_by) ?> | + Дата создания: created_at)) ?> +
+ +
+ content) ?> +
+ group_id == 81) : ?> +
+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Вы уверены, что хотите удалить статью?', + 'method' => 'post', + ], + ]) ?> +
+ +
+ + -- 2.39.5