init Area full CRUD

This commit is contained in:
2020-10-09 14:19:15 +07:00
parent 5538d74b1b
commit 70db83d3ab
15 changed files with 318 additions and 144 deletions

View File

@@ -1,22 +0,0 @@
<?php
namespace app\widgets;
use yii\base\Widget;
class Department extends Widget {
public $pid;
public function init() {
parent::init();
}
public function run() {
return $this->render("department", [
"lists" => \app\models\Department::find()->andWhere(['pid' => $this->pid])->all()
]);
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace app\widgets;
use yii\base\Widget;
use app\models\SystemLogs;
use app\models\User;
class SystemLogsView extends Widget {
public $type;
public function init() {
parent::init();
}
public function run() {
return $this->render("system-logs-view", [
"logs" => SystemLogs::find()->andWhere(["type" => $this->type])->orderBy(['time' => SORT_DESC])->limit(30)->all(),
"userArray" => User::userArray()
]);
}
}

23
widgets/Tree.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace app\widgets;
use yii\base\Widget;
class Tree extends Widget {
public $model;
public function init() {
parent::init();
}
public function run() {
return $this->render("tree", [
"root" => $this->model->findOne(1),
"model" => $this->model
]);
}
}

24
widgets/TreeSub.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
namespace app\widgets;
use yii\base\Widget;
class TreeSub extends Widget {
public $pid;
public $model;
public function init() {
parent::init();
}
public function run() {
return $this->render("tree-sub", [
"lists" => $this->model->find()->andWhere(['pid' => $this->pid])->all(),
"model" => $this->model
]);
}
}

View File

@@ -0,0 +1,23 @@
<table style="width: 100%;" class="table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>Người dùng</th>
<th>Thời gian</th>
<th>Hành động</th>
<th>Chi tiết</th>
</tr>
</thead>
<tbody>
{$count=1}
{foreach from=$logs item=l}
<tr>
<td>{$count++}</td>
<td>{$userArray[$l->user_id]|default:""}</td>
<td>{$l->time|date_format:"%H:%M:%S %d/%m/%Y"}</td>
<td>{$l->action}</td>
<td>{$l->description}</td>
</tr>
{/foreach}
</tbody>
</table>

View File

@@ -3,7 +3,7 @@
<i class="fa fa-minus-square-o" onclick="common.tree(this);" data="{$l->code}" data-stt="true"></i>
<span class="tree-drop">{$l->code}-{$l->name}</span>
<div id="sub-tree-{$l->code}" style="padding-left: 20px;">
{\app\widgets\Department::widget(["pid"=>$l->code])}
{\app\widgets\TreeSub::widget(["pid"=>$l->code,"model"=>$model])}
</div>
</div>
{/foreach}

7
widgets/views/tree.tpl Normal file
View File

@@ -0,0 +1,7 @@
<div style="cursor: pointer;">
<i class="fa fa-minus-square-o" onclick="common.tree(this);" data="1" data-stt="true"></i>
<b class="tree tree-drop" data="0">{$root->code}-{$root->name}</b>
<div id="sub-tree-1" style="padding-left: 20px;">
{\app\widgets\TreeSub::widget(["pid"=>1,"model"=>$model])}
</div>
</div>