diff --git a/helpers/AreaGrid.php b/helpers/AreaGrid.php
new file mode 100644
index 00000000..639b53ae
--- /dev/null
+++ b/helpers/AreaGrid.php
@@ -0,0 +1,13 @@
+pid]) ? $departmentArray[$model->pid] : "";
+ };
+ }
+
+}
diff --git a/helpers/CommonGrid.php b/helpers/CommonGrid.php
index 75688fc9..7c7ec76d 100644
--- a/helpers/CommonGrid.php
+++ b/helpers/CommonGrid.php
@@ -62,4 +62,24 @@ class CommonGrid {
};
}
+ public static function checkbox($type) {
+ return function($model) use ($type) {
+ if ($model->id == 1)
+ return "";
+ return "";
+ };
+ }
+
+ public static function rows($type) {
+ return function($model, $index, $widget, $grid) use ($type) {
+ return [
+ "onclick" => "common.form(this, '{$type}');",
+ "style" => "cursor: pointer;",
+ "data" => [
+ "href" => Url::to(["update", "id" => $model->id])
+ ]
+ ];
+ };
+ }
+
}
diff --git a/helpers/DepartmentGrid.php b/helpers/DepartmentGrid.php
index 19680f33..6bff3f08 100644
--- a/helpers/DepartmentGrid.php
+++ b/helpers/DepartmentGrid.php
@@ -2,9 +2,6 @@
namespace app\helpers;
-use yii\helpers\Html;
-use yii\helpers\Url;
-
class DepartmentGrid extends CommonGrid {
public static function pid($departmentArray) {
@@ -13,24 +10,4 @@ class DepartmentGrid extends CommonGrid {
};
}
- public static function checkbox() {
- return function($model) {
- if ($model->id == 1)
- return "";
- return "";
- };
- }
-
- public static function rows() {
- return function($model, $index, $widget, $grid) {
- return [
- "onclick" => "common.form(this, 'department');",
- "style" => "cursor: pointer;",
- "data" => [
- "href" => Url::to(["update", "id" => $model->id])
- ]
- ];
- };
- }
-
}
diff --git a/views/area/_form.php b/views/area/_form.php
deleted file mode 100644
index 688a772b..00000000
--- a/views/area/_form.php
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
diff --git a/views/area/_search.php b/views/area/_search.php
deleted file mode 100644
index c086554e..00000000
--- a/views/area/_search.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- ['index'],
- 'method' => 'get',
- 'options' => [
- 'data-pjax' => 1
- ],
- ]); ?>
-
- = $form->field($model, 'id') ?>
-
- = $form->field($model, 'code') ?>
-
- = $form->field($model, 'pid') ?>
-
- = $form->field($model, 'name') ?>
-
- = $form->field($model, 'description') ?>
-
- field($model, 'created_at') ?>
-
- field($model, 'modified_at') ?>
-
-
- = Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
- = Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
-
-
-
-
-
diff --git a/views/area/create.php b/views/area/create.php
deleted file mode 100644
index b761aa06..00000000
--- a/views/area/create.php
+++ /dev/null
@@ -1,21 +0,0 @@
-title = 'Create Area';
-$this->params['breadcrumbs'][] = ['label' => 'Areas', 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
-
- = $this->render('_form', [
- 'model' => $model,
- ]) ?>
-
-
diff --git a/views/area/index.php b/views/area/index.php
deleted file mode 100644
index eb3dda80..00000000
--- a/views/area/index.php
+++ /dev/null
@@ -1,41 +0,0 @@
-title = 'Areas';
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
-
- render('_search', ['model' => $searchModel]); ?>
-
-
- = Html::a('Create Area', ['create'], ['class' => 'btn btn-success']) ?>
-
-
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
-
- 'id',
- 'code',
- 'pid',
- 'name',
- 'description:ntext',
- //'created_at',
- //'modified_at',
-
- ['class' => 'yii\grid\ActionColumn'],
- ],
- ]); ?>
-
-
diff --git a/views/area/index.tpl b/views/area/index.tpl
index 4efb02a7..d24f2988 100644
--- a/views/area/index.tpl
+++ b/views/area/index.tpl
@@ -30,12 +30,12 @@
{GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
- 'layout'=> \app\helpers\DepartmentGrid::getLayout(),
+ 'layout'=> \app\helpers\AreaGrid::getLayout(),
'tableOptions' => [
'class' => 'table table-striped table-bordered table-hover',
'style' => 'background:#fff;min-width:700px;'
],
- 'rowOptions' => \app\helpers\DepartmentGrid::rows(),
+ 'rowOptions' => \app\helpers\AreaGrid::rows("area"),
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
@@ -43,11 +43,11 @@
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%']
],
[
- 'header' => "",
+ 'header' => "",
'format' => 'raw',
'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
- 'value' => \app\helpers\DepartmentGrid::checkbox()
+ 'value' => \app\helpers\AreaGrid::checkbox("area")
],
'code',
'pid',
@@ -55,11 +55,11 @@
'description:ntext',
[
'attribute' => 'created_at',
- 'value' => \app\helpers\DepartmentGrid::createdAt()
+ 'value' => \app\helpers\AreaGrid::createdAt()
],
[
'attribute' => 'modified_at',
- 'value' => \app\helpers\DepartmentGrid::modifiedAt()
+ 'value' => \app\helpers\AreaGrid::modifiedAt()
]
]
])}
diff --git a/views/area/update.php b/views/area/update.php
deleted file mode 100644
index aecd227c..00000000
--- a/views/area/update.php
+++ /dev/null
@@ -1,21 +0,0 @@
-title = 'Update Area: ' . $model->name;
-$this->params['breadcrumbs'][] = ['label' => 'Areas', 'url' => ['index']];
-$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
-$this->params['breadcrumbs'][] = 'Update';
-?>
-
-
-
= Html::encode($this->title) ?>
-
- = $this->render('_form', [
- 'model' => $model,
- ]) ?>
-
-
diff --git a/views/area/view.php b/views/area/view.php
deleted file mode 100644
index eb5cea84..00000000
--- a/views/area/view.php
+++ /dev/null
@@ -1,41 +0,0 @@
-title = $model->name;
-$this->params['breadcrumbs'][] = ['label' => 'Areas', 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
-
-
- = 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',
- ],
- ]) ?>
-
-
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'id',
- 'code',
- 'pid',
- 'name',
- 'description:ntext',
- 'created_at',
- 'modified_at',
- ],
- ]) ?>
-
-
diff --git a/views/department/index.tpl b/views/department/index.tpl
index 5c0953a4..18b6e6c4 100644
--- a/views/department/index.tpl
+++ b/views/department/index.tpl
@@ -42,7 +42,7 @@
'class' => 'table table-striped table-bordered table-hover',
'style' => 'background:#fff;min-width:700px;'
],
- 'rowOptions' => \app\helpers\DepartmentGrid::rows(),
+ 'rowOptions' => \app\helpers\DepartmentGrid::rows("department"),
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
@@ -54,7 +54,7 @@
'format' => 'raw',
'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
- 'value' => \app\helpers\DepartmentGrid::checkbox()
+ 'value' => \app\helpers\DepartmentGrid::checkbox("department")
],
'code',
'name',
diff --git a/views/device/index.tpl b/views/device/index.tpl
index c588b8aa..d5eee435 100644
--- a/views/device/index.tpl
+++ b/views/device/index.tpl
@@ -42,7 +42,7 @@
'class' => 'table table-striped table-bordered table-hover',
'style' => 'background:#fff;min-width:700px;'
],
- 'rowOptions' => \app\helpers\DepartmentGrid::rows(),
+ 'rowOptions' => \app\helpers\DepartmentGrid::rows("device"),
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
@@ -54,7 +54,7 @@
'format' => 'raw',
'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
- 'value' => \app\helpers\DepartmentGrid::checkbox()
+ 'value' => \app\helpers\DepartmentGrid::checkbox("device")
],
'name',
'ip_address',