diff --git a/CHANGELOG.md b/CHANGELOG.md index 65a4276f..c7beee4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,16 @@ # Changelog -## [2026-02-27] - Modernization, Backend Tools & Dashboard Enhancements +## [2026-02-27] - Modernization, Backend Tools, GIS Refactoring & Dashboard Enhancements ### Added +- **GIS Module Refactoring:** + - Renamed legacy `map` module to `gis` for clarity and standardization. + - Performed system-wide namespace refactoring to `backend\modules\gis`. + - Redesigned GIS main dashboard with a modern Interactive Card UI and Font Awesome 5.11 icons. +- **RBAC for GIS:** + - Created a new RBAC role `gis` (GIS Data Manager) via database migration. + - Added `/gis/*` permission covering all GIS module actions. + - Configured `authManager` in console application to utilize shared RBAC files at `@backend/rbac/`. - **Premium Backend Dashboard:** - Redesigned the main dashboard with categorized module shortcuts for better organization. - Categorized modules into: Administration & Strategy, Assets & Resources, and Public Services & Revenue. diff --git a/backend/config/main.php b/backend/config/main.php index 8b12c8e7..806c04c0 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -32,6 +32,9 @@ return [ 'forum' => [ 'class' => 'backend\modules\forum\Module', ], + 'gis' => [ + 'class' => 'backend\modules\gis\Module', + ], 'gridview' => [ 'class' => '\kartik\grid\Module' ], diff --git a/backend/modules/gis/Module.php b/backend/modules/gis/Module.php new file mode 100755 index 00000000..1135dfd3 --- /dev/null +++ b/backend/modules/gis/Module.php @@ -0,0 +1,24 @@ +render('index'); + } +} diff --git a/backend/modules/gis/controllers/GeoFeaturesController.php b/backend/modules/gis/controllers/GeoFeaturesController.php new file mode 100755 index 00000000..aa35b093 --- /dev/null +++ b/backend/modules/gis/controllers/GeoFeaturesController.php @@ -0,0 +1,151 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ] + ); + } + + /** + * Lists all GisGeoFeatures models. + * + * @return string + */ + public function actionIndex() + { + $searchModel = new GisGeoFeaturesSearch(); + $dataProvider = $searchModel->search($this->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single GisGeoFeatures 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 GisGeoFeatures model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return string|\yii\web\Response + */ + public function actionCreate() + { + $model = new GisGeoFeatures(); + + if ($this->request->isPost && $model->load(Yii::$app->request->post())) { + $geo = json_decode(Yii::$app->request->post('GisGeoFeatures')['geometry'], true); + + if ($geo && isset($geo['type'], $geo['coordinates'])) { + $model->geometry = new \yii\db\Expression("ST_GeomFromGeoJSON('" . json_encode($geo) . "')"); + $model->type = $geo['type']; // ✅ ดึง type จาก GeoJSON โดยตรง + } + + if ($model->save(false)) { + return $this->redirect(['view', 'id' => $model->id]); + } + } else { + $model->loadDefaultValues(); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing GisGeoFeatures 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 ($model->load(Yii::$app->request->post())) { + $geo = json_decode(Yii::$app->request->post('GisGeoFeatures')['geometry'], true); + + if ($geo && isset($geo['type'], $geo['coordinates'])) { + $model->geometry = new \yii\db\Expression("ST_GeomFromGeoJSON('" . json_encode($geo) . "')"); + $model->type = $geo['type']; // ✅ ตั้งค่า type เช่นกัน + } + + if ($model->save(false)) { + return $this->redirect(['view', 'id' => $model->id]); + } + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing GisGeoFeatures 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 GisGeoFeatures 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 GisGeoFeatures the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = GisGeoFeatures::findOne(['id' => $id])) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/backend/modules/gis/controllers/GisBaseController.php b/backend/modules/gis/controllers/GisBaseController.php new file mode 100755 index 00000000..cb5265b6 --- /dev/null +++ b/backend/modules/gis/controllers/GisBaseController.php @@ -0,0 +1,134 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ] + ); + } + + /** + * Lists all GisBase models. + * + * @return string + */ + public function actionIndex() + { + $searchModel = new GisBaseSearch(); + $dataProvider = $searchModel->search($this->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single GisBase 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 GisBase model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return string|\yii\web\Response + */ + public function actionCreate() + { + $model = new GisBase(); + + if ($this->request->isPost) { + if ($model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + } else { + $model->loadDefaultValues(); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing GisBase 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 GisBase 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 GisBase 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 GisBase the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = GisBase::findOne(['id' => $id])) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/backend/modules/gis/controllers/MapController.php b/backend/modules/gis/controllers/MapController.php new file mode 100755 index 00000000..c70921c6 --- /dev/null +++ b/backend/modules/gis/controllers/MapController.php @@ -0,0 +1,115 @@ +render('index'); + } + + public function actionMap() + { + return $this->render('map'); + } + + public function actionGeojson() + { + Yii::$app->response->format = Response::FORMAT_JSON; + + $gis_base_id = Yii::$app->request->get('GisGeoFeatures')['gis_base_id'] ?? null; + + $features = []; + + // ✅ โหลดข้อมูลจากตาราง gis_tambon เสมอ + $tambonRows = (new Query()) + ->select(['id', 'tb_name_t', 'tb_code', 'ST_AsGeoJSON(geom) AS geojson']) + ->from('gis_tambon') + ->where(['id' => 7662]) + ->all(); + + foreach ($tambonRows as $row) { + $features[] = [ + 'type' => 'Feature', + 'geometry' => json_decode($row['geojson']), + 'properties' => [ + 'id' => $row['id'], + 'name' => $row['tb_name_t'], + 'interactive' => false + ] + ]; + } + + // ✅ โหลดข้อมูลจาก gis_geo_features ตาม gis_base_id (ถ้ามี) + $geoQuery = (new Query()) + ->select([ + 'f.id', + 'f.name', + 'ST_AsGeoJSON(f.geometry) AS geojson', + 'b.color' // 👈 ดึงสีจากตาราง gis_base + ]) + ->from(['f' => 'gis_geo_features']) + ->leftJoin(['b' => 'gis_base'], 'f.gis_base_id = b.id'); // 👈 join + + if ($gis_base_id) { + $geoQuery->where(['f.gis_base_id' => $gis_base_id]); + } + + $geoRows = $geoQuery->all(); + + foreach ($geoRows as $row) { + $features[] = [ + 'type' => 'Feature', + 'geometry' => json_decode($row['geojson']), + 'properties' => [ + 'id' => $row['id'], + 'name' => $row['name'], + 'color' => $row['color'] ?? '#3388ff' // ✅ กำหนดสี default ถ้าไม่มี + ] + ]; + } + + return [ + 'type' => 'FeatureCollection', + 'features' => $features + ]; + } + /*public function actionGeojson() + { + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + + $gis_base_id = Yii::$app->request->get('GisGeoFeatures')['gis_base_id'] ?? null; + + $query = GisGeoFeatures::find(); + + if ($gis_base_id) { + $query->andWhere(['gis_base_id' => $gis_base_id]); + } + + $features = $query->all(); + + $geojson = [ + "type" => "FeatureCollection", + "features" => [] + ]; + + foreach ($features as $f) { + $geojson['features'][] = [ + "type" => "Feature", + "geometry" => json_decode($f->geometry), + "properties" => [ + "name" => $f->name + ] + ]; + } + + return $geojson; + }*/ + +} diff --git a/backend/modules/gis/models/GisBaseSearch.php b/backend/modules/gis/models/GisBaseSearch.php new file mode 100755 index 00000000..315e9efb --- /dev/null +++ b/backend/modules/gis/models/GisBaseSearch.php @@ -0,0 +1,74 @@ +load()` method. + * + * @return ActiveDataProvider + */ + public function search($params, $formName = null) + { + $query = GisBase::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params, $formName); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + 'created_by' => $this->created_by, + 'updated_by' => $this->updated_by, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'description', $this->description]); + + return $dataProvider; + } +} diff --git a/backend/modules/gis/models/GisGeoFeaturesSearch.php b/backend/modules/gis/models/GisGeoFeaturesSearch.php new file mode 100755 index 00000000..f9e64c36 --- /dev/null +++ b/backend/modules/gis/models/GisGeoFeaturesSearch.php @@ -0,0 +1,76 @@ +load()` method. + * + * @return ActiveDataProvider + */ + public function search($params, $formName = null) + { + $query = GisGeoFeatures::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params, $formName); + + 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, + 'gis_base_id' => $this->gis_base_id, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + 'created_by' => $this->created_by, + 'updated_by' => $this->updated_by, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'geometry', $this->geometry]) + ->andFilterWhere(['like', 'type', $this->type]); + + return $dataProvider; + } +} diff --git a/backend/modules/gis/views/default/index.php b/backend/modules/gis/views/default/index.php new file mode 100755 index 00000000..1661636e --- /dev/null +++ b/backend/modules/gis/views/default/index.php @@ -0,0 +1,109 @@ +title = 'ระบบภูมิสารสนเทศ (GIS)'; +$this->params['breadcrumbs'][] = $this->title; +?> + + + +
+ +
+

ศูนย์จัดการข้อมูลภูมิสารสนเทศ

+

จัดการข้อมูลตำแหน่ง พิกัด และแผนที่ยุทธศาสตร์เพื่อการพัฒนาท้องถิ่น

+
+ +
+ + + + + + + + +
+ +
+ คำแนะนำ: คุณสามารถดึงข้อมูลพิกัดจากระบบ GIS นี้ไปแสดงผลที่หน้าเว็บไซต์ (Frontend) เพื่ออำนวยความสะดวกแก่ประชาชนได้ทันที +
+
diff --git a/backend/modules/gis/views/geo-features/_form.php b/backend/modules/gis/views/geo-features/_form.php new file mode 100755 index 00000000..601dff26 --- /dev/null +++ b/backend/modules/gis/views/geo-features/_form.php @@ -0,0 +1,95 @@ + + +registerCssFile("https://unpkg.com/leaflet/dist/leaflet.css") ?> +registerJsFile("https://unpkg.com/leaflet/dist/leaflet.js") ?> + +registerCssFile("https://unpkg.com/leaflet-draw/dist/leaflet.draw.css") ?> +registerJsFile("https://unpkg.com/leaflet-draw/dist/leaflet.draw.js") ?> + +
+ + + +
+ + + + field($model, 'gis_base_id')->dropDownList(ArrayHelper::map(GisBase::find()->all(), 'id', 'name')) ?> + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'geometry')->label(false)->hiddenInput(['id' => 'geometry']) ?> + + +
+ 'btn btn-success']) ?> +
+ + + +
\ No newline at end of file diff --git a/backend/modules/gis/views/geo-features/_search.php b/backend/modules/gis/views/geo-features/_search.php new file mode 100755 index 00000000..08b0c0ca --- /dev/null +++ b/backend/modules/gis/views/geo-features/_search.php @@ -0,0 +1,43 @@ + + + diff --git a/backend/modules/gis/views/geo-features/create.php b/backend/modules/gis/views/geo-features/create.php new file mode 100755 index 00000000..ea3c04a3 --- /dev/null +++ b/backend/modules/gis/views/geo-features/create.php @@ -0,0 +1,20 @@ +title = 'เพิ่มรายการ'; +$this->params['breadcrumbs'][] = ['label' => 'รายการ', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/gis/views/geo-features/index.php b/backend/modules/gis/views/geo-features/index.php new file mode 100755 index 00000000..9aaa8584 --- /dev/null +++ b/backend/modules/gis/views/geo-features/index.php @@ -0,0 +1,56 @@ +title = 'ข้อมูลพิกัด'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + render('_search', ['model' => $searchModel]); ?> + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + //'id', + [ + 'attribute' => 'gis_base_id', + 'value' => function($model) { + return $model->gisBase->name; + } + ], + 'name', + //'geometry', + //'type', + //'created_at', + //'updated_at', + //'created_by', + //'updated_by', + [ + 'class' => ActionColumn::className(), + 'urlCreator' => function ($action, GisGeoFeatures $model, $key, $index, $column) { + return Url::toRoute([$action, 'id' => $model->id]); + } + ], + ], + ]); ?> + + +
diff --git a/backend/modules/gis/views/geo-features/update.php b/backend/modules/gis/views/geo-features/update.php new file mode 100755 index 00000000..a679c7cb --- /dev/null +++ b/backend/modules/gis/views/geo-features/update.php @@ -0,0 +1,21 @@ +title = 'Update Gis Geo Features: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Gis Geo Features', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/gis/views/geo-features/view.php b/backend/modules/gis/views/geo-features/view.php new file mode 100755 index 00000000..00f02770 --- /dev/null +++ b/backend/modules/gis/views/geo-features/view.php @@ -0,0 +1,44 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Gis Geo Features', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'gis_base_id', + 'name', + 'geometry', + 'type', + 'created_at', + 'updated_at', + 'created_by', + 'updated_by', + ], + ]) ?> + +
diff --git a/backend/modules/gis/views/gis-base/_form.php b/backend/modules/gis/views/gis-base/_form.php new file mode 100755 index 00000000..e0c70a0c --- /dev/null +++ b/backend/modules/gis/views/gis-base/_form.php @@ -0,0 +1,29 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + field($model, 'color')->widget(ColorInput::classname(), [ + 'options' => ['placeholder' => 'Select color ...'], + ])?> + field($model, 'description')->textarea(['rows' => 6]) ?> + + +
+ 'btn btn-success']) ?> +
+ + + +
diff --git a/backend/modules/gis/views/gis-base/_search.php b/backend/modules/gis/views/gis-base/_search.php new file mode 100755 index 00000000..3d09a09a --- /dev/null +++ b/backend/modules/gis/views/gis-base/_search.php @@ -0,0 +1,39 @@ + + + diff --git a/backend/modules/gis/views/gis-base/create.php b/backend/modules/gis/views/gis-base/create.php new file mode 100755 index 00000000..27b7708b --- /dev/null +++ b/backend/modules/gis/views/gis-base/create.php @@ -0,0 +1,20 @@ +title = 'เพิ่มชั้นข้อมูล'; +$this->params['breadcrumbs'][] = ['label' => 'ชั้นข้อมูล', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/gis/views/gis-base/index.php b/backend/modules/gis/views/gis-base/index.php new file mode 100755 index 00000000..fa02f551 --- /dev/null +++ b/backend/modules/gis/views/gis-base/index.php @@ -0,0 +1,49 @@ +title = 'ชั้นข้อมูล'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + render('_search', ['model' => $searchModel]); ?> + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + //'id', + 'name', + 'description:ntext', + //'created_at', + //'updated_at', + //'created_by', + //'updated_by', + [ + 'class' => ActionColumn::className(), + 'urlCreator' => function ($action, GisBase $model, $key, $index, $column) { + return Url::toRoute([$action, 'id' => $model->id]); + } + ], + ], + ]); ?> + + +
diff --git a/backend/modules/gis/views/gis-base/update.php b/backend/modules/gis/views/gis-base/update.php new file mode 100755 index 00000000..4adbf15a --- /dev/null +++ b/backend/modules/gis/views/gis-base/update.php @@ -0,0 +1,21 @@ +title = 'แก้ไข: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'ชั้นข้อมูล', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'แก้ไข'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/gis/views/gis-base/view.php b/backend/modules/gis/views/gis-base/view.php new file mode 100755 index 00000000..93475e2f --- /dev/null +++ b/backend/modules/gis/views/gis-base/view.php @@ -0,0 +1,42 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Gis Bases', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'name', + 'description:ntext', + 'created_at', + 'updated_at', + 'created_by', + 'updated_by', + ], + ]) ?> + +
diff --git a/backend/modules/gis/views/map/index.php b/backend/modules/gis/views/map/index.php new file mode 100755 index 00000000..633f9711 --- /dev/null +++ b/backend/modules/gis/views/map/index.php @@ -0,0 +1,9 @@ + +

map/index

+ +

+ You may change the content of this page by modifying + the file . +

diff --git a/backend/modules/gis/views/map/map.php b/backend/modules/gis/views/map/map.php new file mode 100755 index 00000000..d4b311b1 --- /dev/null +++ b/backend/modules/gis/views/map/map.php @@ -0,0 +1,134 @@ +title = 'แผนที่'; +?> + +registerCssFile("https://unpkg.com/leaflet/dist/leaflet.css") ?> +registerJsFile("https://unpkg.com/leaflet/dist/leaflet.js") ?> + +registerCssFile("https://unpkg.com/leaflet-draw/dist/leaflet.draw.css") ?> +registerJsFile("https://unpkg.com/leaflet-draw/dist/leaflet.draw.js") ?> + +registerCssFile("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css") ?> + + + +
เลือกชั้นข้อมูล
+ + +
+ + + + + + + +
+
+

รายการข้อมูล

+
+
+ +
+
+ \ No newline at end of file diff --git a/backend/rbac/items.php b/backend/rbac/items.php index 6ea50712..a19721ed 100755 --- a/backend/rbac/items.php +++ b/backend/rbac/items.php @@ -1,4 +1,5 @@ [ 'type' => 2, @@ -51,4 +52,15 @@ return [ 'pms_forum', ], ], + '/gis/*' => [ + 'type' => 2, + 'description' => 'Access to all GIS module actions', + ], + 'gis' => [ + 'type' => 1, + 'description' => 'GIS Data Manager', + 'children' => [ + '/gis/*', + ], + ], ]; diff --git a/backend/themes/nikom/views/layouts/_menu.php b/backend/themes/nikom/views/layouts/_menu.php index 29e14644..8039d6e6 100755 --- a/backend/themes/nikom/views/layouts/_menu.php +++ b/backend/themes/nikom/views/layouts/_menu.php @@ -59,21 +59,13 @@ if (Yii::$app->user->can('cms')) { ]]; - $menu[] = ['label' => ' เมนู', 'url' => ['/cms/menu/index'], 'items' => [ + /*$menu[] = ['label' => ' เมนู', 'url' => ['/cms/menu/index'], 'items' => [ ['label' => 'กลุ่มเมนู', 'url' => ['/cms/menu-group/index']], ['label' => 'เมนู', 'url' => ['/cms/menu/index']], - ]]; - /*$menu[] = ['label' => ' คนเก่งคนดี', 'url' => ['/cms/great-person/index'], 'items' => [ - ['label' => 'รายการคนเก่งคนดี', 'url' => ['/cms/great-person/index']], - ['label' => 'เพิ่มคนเก่งคนดี', 'url' => ['/cms/great-person/create']], - ]]; - $menu[] = ['label' => ' LINE Notify', 'url' => ['/cms/line-notify/index'], 'items' => [ - ['label' => 'รายการแจ้งเตือน', 'url' => ['/cms/line-notify/index']], - ['label' => 'เพิ่มรายการแจ้งเตือน', 'url' => ['/cms/line-notify/create']], ]];*/ } -//Administrator +//Forum if (Yii::$app->user->can('forum')) { $menu[] = ['label' => 'ระบบกระดานข่าว', 'options' => ['class' => 'navigation-header']]; $menu[] = ['label' => ' กระทู้', 'url' => ['/forum/thread/index'], 'items' => [ @@ -82,19 +74,29 @@ if (Yii::$app->user->can('forum')) { ['label' => 'รายการคอมเม้น', 'url' => ['/forum/comment/index']], ]]; -}//user can administrator +}//user can forum + +//GIS +if (Yii::$app->user->can('gis')) { + $menu[] = ['label' => 'ระบบภูมิสารสนเทศ (GIS)', 'options' => ['class' => 'navigation-header']]; + $menu[] = ['label' => ' ระบบ GIS', 'url' => ['/gis/default/index'], 'items' => [ + ['label' => 'ภาพรวมแผนที่', 'url' => ['/gis/map/index']], + ['label' => 'จัดการจุดพิกัด', 'url' => ['/gis/geo-features/index']], + ['label' => 'ข้อมูลพื้นฐาน GIS', 'url' => ['/gis/gis-base/index']], + ]]; +} //Administrator if (Yii::$app->user->can('administrator')) { $menu[] = ['label' => 'ผู้ดูแลระบบ', 'options' => ['class' => 'navigation-header']]; - $menu[] = ['label' => ' ผู้ใช้งาน', 'url' => ['/administrator/user/index'], 'items' => [ - ['label' => 'รายการผู้ใช้งาน', 'url' => ['/administrator/user/index']], - ['label' => 'เพิ่มผู้ใช้งาน', 'url' => ['/administrator/user/create']], - //['label' => 'เมนู', 'url' => ['/administrator/menu/index']], - ]]; + $menu[] = ['label' => ' เมนูหน้าบ้าน', 'url' => ['/administrator/menu-frontend/index']]; $menu[] = ['label' => ' จัดการไฟล์ธีม', 'url' => ['/administrator/theme-editor/index']]; $menu[] = ['label' => ' จัดการไฟล์อัปโหลด', 'url' => ['/administrator/filemanager/index']]; + $menu[] = ['label' => ' ผู้ใช้งาน', 'url' => ['/administrator/user/index'], 'items' => [ + ['label' => 'รายการผู้ใช้งาน', 'url' => ['/administrator/user/index']], + ['label' => 'เพิ่มผู้ใช้งาน', 'url' => ['/administrator/user/create']], + ]]; $menu[] = ['label' => ' ควบคุมสิทธิ์การเข้าถึง', 'url' => ['/admin/assignment/index'], 'items' => [ ['label' => 'การกำหนด', 'url' => ['/admin/assignment/index']], ['label' => 'บทบาท', 'url' => ['/admin/role/index']], diff --git a/backend/views/site/_menu.php b/backend/views/site/_menu.php new file mode 100644 index 00000000..2fc9a129 --- /dev/null +++ b/backend/views/site/_menu.php @@ -0,0 +1,149 @@ + + +
+ 1. งานบริหารและยุทธศาสตร์ +
+
+
+ +
+ งานสารบรรณ + E-Saraban +
+
+
+ +
+ งานบุคลากร + Personnel +
+
+
+ +
+ ลงเวลาทำงาน + Attendance +
+
+
+ +
+ ไปราชการ + Travel +
+
+
+ +
+ งานแผน + Planning +
+
+
+ +
+ งานโปร่งใส ITA + Transparency +
+
+
+ + +
+ 2. งานพัสดุและทรัพยากร +
+
+
+ +
+ งานครุภัณฑ์ + Supply +
+
+
+ +
+ งานวัสดุ + Durable +
+
+
+ +
+ แจ้งซ่อม + Maintenance +
+
+
+ +
+ จองรถ + Vehicles +
+
+
+ +
+ จองห้องประชุม + Rooms +
+
+
+ + +
+ 3. งานบริการสาธารณะและรายได้ +
+
+
+ +
+ งานรายได้/ภาษี + Taxation +
+
+
+ +
+ งานประปา + Waterworks +
+
+
+ +
+ สวัสดิการสังคม + Welfare +
+
+
+ +
+ จัดการขยะ + Waste Mgmt +
+
+
+ +
+ EMS 1669 + Emergency +
+
+
+ +
+ งานป้องกันฯ + Disaster +
+
+
+ +
+ GIS Map + Strategic +
+
+
\ No newline at end of file diff --git a/backend/views/site/index.php b/backend/views/site/index.php index acb2695e..a1fcce21 100755 --- a/backend/views/site/index.php +++ b/backend/views/site/index.php @@ -186,152 +186,7 @@ $recentPosts = CmsPost::find()->orderBy(['created_at' => SORT_DESC])->limit(5)-> - -
- 1. งานบริหารและยุทธศาสตร์ -
-
-
- -
- งานสารบรรณ - E-Saraban -
-
-
- -
- งานบุคลากร - Personnel -
-
-
- -
- ลงเวลาทำงาน - Attendance -
-
-
- -
- ไปราชการ - Travel -
-
-
- -
- งานแผน - Planning -
-
-
- -
- งานโปร่งใส ITA - Transparency -
-
-
- - -
- 2. งานพัสดุและทรัพยากร -
-
-
- -
- งานครุภัณฑ์ - Supply -
-
-
- -
- งานวัสดุ - Durable -
-
-
- -
- แจ้งซ่อม - Maintenance -
-
-
- -
- จองรถ - Vehicles -
-
-
- -
- จองห้องประชุม - Rooms -
-
-
- - -
- 3. งานบริการสาธารณะและรายได้ -
-
-
- -
- งานรายได้/ภาษี - Taxation -
-
-
- -
- งานประปา - Waterworks -
-
-
- -
- สวัสดิการสังคม - Welfare -
-
-
- -
- จัดการขยะ - Waste Mgmt -
-
-
- -
- EMS 1669 - Emergency -
-
-
- -
- งานป้องกันฯ - Disaster -
-
-
- -
- GIS Map - Strategic -
-
-
+render('_menu') ?>
@@ -450,7 +305,7 @@ $recentPosts = CmsPost::find()->orderBy(['created_at' => SORT_DESC])->limit(5)->
ระบบจัดการเว็บไซต์
-

เวอร์ชัน 2.0.0 (Yii2 Core)
พัฒนาโดย HANUMANIT Co., Ltd.

+

เวอร์ชัน 2.0.0
พัฒนาโดย HANUMANIT Co., Ltd.


SSL Protected
diff --git a/console/config/main.php b/console/config/main.php index a67be5c0..402cdb93 100755 --- a/console/config/main.php +++ b/console/config/main.php @@ -30,6 +30,12 @@ return [ ], ], ], + 'authManager' => [ + 'class' => 'yii\rbac\PhpManager', + 'itemFile' => '@backend/rbac/items.php', + 'assignmentFile' => '@backend/rbac/assignments.php', + 'ruleFile' => '@backend/rbac/rules.php', + ], ], 'params' => $params, ]; diff --git a/console/migrations/m260227_061319_add_gis_rbac_role.php b/console/migrations/m260227_061319_add_gis_rbac_role.php new file mode 100644 index 00000000..ee3fed79 --- /dev/null +++ b/console/migrations/m260227_061319_add_gis_rbac_role.php @@ -0,0 +1,60 @@ +authManager; + + // 1. Create the permission for the entire GIS module + $gisPermission = $auth->getPermission('/gis/*'); + if (!$gisPermission) { + $gisPermission = $auth->createPermission('/gis/*'); + $gisPermission->description = 'Access to all GIS module actions'; + $auth->add($gisPermission); + } + + // 2. Create the 'gis' role + $gisRole = $auth->getRole('gis'); + if (!$gisRole) { + $gisRole = $auth->createRole('gis'); + $gisRole->description = 'GIS Data Manager'; + $auth->add($gisRole); + } + + // 3. Assign permission to the role + if (!$auth->hasChild($gisRole, $gisPermission)) { + $auth->addChild($gisRole, $gisPermission); + } + + echo "RBAC: Role 'gis' and permission '/gis/*' have been created successfully.\n"; + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $auth = Yii::$app->authManager; + + $gisRole = $auth->getRole('gis'); + if ($gisRole) { + $auth->remove($gisRole); + } + + $gisPermission = $auth->getPermission('/gis/*'); + if ($gisPermission) { + $auth->remove($gisPermission); + } + + return true; + } +}