update Area + Device
This commit is contained in:
parent
2d15fc1c14
commit
0273aa2179
323
access_control.sql
Normal file
323
access_control.sql
Normal file
|
@ -0,0 +1,323 @@
|
|||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.9.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Oct 08, 2020 at 12:11 PM
|
||||
-- Server version: 10.4.8-MariaDB
|
||||
-- PHP Version: 7.1.33
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET AUTOCOMMIT = 0;
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `access_control`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `area`
|
||||
--
|
||||
|
||||
CREATE TABLE `area` (
|
||||
`id` int(11) NOT NULL,
|
||||
`code` int(11) NOT NULL,
|
||||
`pid` int(11) NOT NULL DEFAULT 0,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`created_at` int(11) NOT NULL DEFAULT 0,
|
||||
`modified_at` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Dumping data for table `area`
|
||||
--
|
||||
|
||||
INSERT INTO `area` (`id`, `code`, `pid`, `name`, `description`, `created_at`, `modified_at`) VALUES
|
||||
(1, 1, 0, 'AreaName', NULL, 0, 0);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `auth_assignment`
|
||||
--
|
||||
|
||||
CREATE TABLE `auth_assignment` (
|
||||
`item_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`user_id` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `auth_assignment`
|
||||
--
|
||||
|
||||
INSERT INTO `auth_assignment` (`item_name`, `user_id`, `created_at`) VALUES
|
||||
('administrator', '1', 1569900053);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `auth_item`
|
||||
--
|
||||
|
||||
CREATE TABLE `auth_item` (
|
||||
`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`type` smallint(6) NOT NULL,
|
||||
`description` text COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`rule_name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`data` blob DEFAULT NULL,
|
||||
`created_at` int(11) DEFAULT NULL,
|
||||
`updated_at` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `auth_item`
|
||||
--
|
||||
|
||||
INSERT INTO `auth_item` (`name`, `type`, `description`, `rule_name`, `data`, `created_at`, `updated_at`) VALUES
|
||||
('administrator', 1, 'Administrator', NULL, NULL, 1535011160, 1535011160);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `auth_item_child`
|
||||
--
|
||||
|
||||
CREATE TABLE `auth_item_child` (
|
||||
`parent` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`child` varchar(64) COLLATE utf8_unicode_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `auth_rule`
|
||||
--
|
||||
|
||||
CREATE TABLE `auth_rule` (
|
||||
`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`data` blob DEFAULT NULL,
|
||||
`created_at` int(11) DEFAULT NULL,
|
||||
`updated_at` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `department`
|
||||
--
|
||||
|
||||
CREATE TABLE `department` (
|
||||
`id` int(11) NOT NULL,
|
||||
`code` int(11) NOT NULL,
|
||||
`pid` int(11) NOT NULL,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`created_at` int(11) NOT NULL,
|
||||
`modified_at` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Dumping data for table `department`
|
||||
--
|
||||
|
||||
INSERT INTO `department` (`id`, `code`, `pid`, `name`, `created_at`, `modified_at`) VALUES
|
||||
(1, 1, 0, 'CompanyName', 0, 0),
|
||||
(2, 2, 1, 'Phòng CNTT', 1602151686, 1602151686),
|
||||
(3, 3, 2, 'Phòng AI', 1602151780, 1602151780),
|
||||
(4, 4, 2, 'Phòng OP', 1602151789, 1602151828);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `device`
|
||||
--
|
||||
|
||||
CREATE TABLE `device` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`serial` varchar(50) DEFAULT NULL,
|
||||
`ip_address` varchar(20) NOT NULL,
|
||||
`status` int(11) NOT NULL,
|
||||
`type` int(11) NOT NULL,
|
||||
`area_id` int(11) NOT NULL,
|
||||
`created_at` int(11) NOT NULL DEFAULT 0,
|
||||
`modified_at` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `system_logs`
|
||||
--
|
||||
|
||||
CREATE TABLE `system_logs` (
|
||||
`id` int(11) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`time` int(11) NOT NULL,
|
||||
`action` varchar(10) NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`type` varchar(100) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Dumping data for table `system_logs`
|
||||
--
|
||||
|
||||
INSERT INTO `system_logs` (`id`, `user_id`, `time`, `action`, `description`, `type`) VALUES
|
||||
(1, 1, 1602151686, 'insert', 'Thêm mới phòng ban: Phòng CNTT', 'department'),
|
||||
(2, 1, 1602151780, 'insert', 'Thêm mới phòng ban: Phòng AI', 'department'),
|
||||
(3, 1, 1602151789, 'insert', 'Thêm mới phòng ban: Phòng OP', 'department'),
|
||||
(4, 1, 1602151794, 'update', 'Chỉnh sửa phòng ban: Phòng OP', 'department'),
|
||||
(5, 1, 1602151810, 'insert', 'Thêm mới phòng ban: gffdg', 'department'),
|
||||
(6, 1, 1602151813, 'delete', 'Xóa phòng ban: gffdg', 'department'),
|
||||
(7, 1, 1602151828, 'update', 'Chỉnh sửa phòng ban: Phòng OP', 'department');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `user`
|
||||
--
|
||||
|
||||
CREATE TABLE `user` (
|
||||
`id` int(11) NOT NULL,
|
||||
`first_name` varchar(250) NOT NULL,
|
||||
`last_name` varchar(250) DEFAULT NULL,
|
||||
`phone_number` varchar(30) DEFAULT NULL,
|
||||
`username` varchar(250) NOT NULL,
|
||||
`email` varchar(500) DEFAULT NULL,
|
||||
`password` varchar(250) NOT NULL,
|
||||
`authKey` varchar(250) DEFAULT NULL,
|
||||
`password_reset_token` varchar(250) DEFAULT NULL,
|
||||
`user_image` varchar(500) DEFAULT NULL,
|
||||
`quota` int(11) NOT NULL DEFAULT 2
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Dumping data for table `user`
|
||||
--
|
||||
|
||||
INSERT INTO `user` (`id`, `first_name`, `last_name`, `phone_number`, `username`, `email`, `password`, `authKey`, `password_reset_token`, `user_image`, `quota`) VALUES
|
||||
(1, 'Administrator', '', '12313', 'admin', 'admin@bitraffic.vn', 'ceea23519f6f86ad67e9f798bf8002cb', NULL, NULL, '', 2);
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `area`
|
||||
--
|
||||
ALTER TABLE `area`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `auth_assignment`
|
||||
--
|
||||
ALTER TABLE `auth_assignment`
|
||||
ADD PRIMARY KEY (`item_name`,`user_id`),
|
||||
ADD KEY `auth_assignment_user_id_idx` (`user_id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `auth_item`
|
||||
--
|
||||
ALTER TABLE `auth_item`
|
||||
ADD PRIMARY KEY (`name`),
|
||||
ADD KEY `rule_name` (`rule_name`),
|
||||
ADD KEY `idx-auth_item-type` (`type`);
|
||||
|
||||
--
|
||||
-- Indexes for table `auth_item_child`
|
||||
--
|
||||
ALTER TABLE `auth_item_child`
|
||||
ADD PRIMARY KEY (`parent`,`child`),
|
||||
ADD KEY `child` (`child`);
|
||||
|
||||
--
|
||||
-- Indexes for table `auth_rule`
|
||||
--
|
||||
ALTER TABLE `auth_rule`
|
||||
ADD PRIMARY KEY (`name`);
|
||||
|
||||
--
|
||||
-- Indexes for table `department`
|
||||
--
|
||||
ALTER TABLE `department`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `device`
|
||||
--
|
||||
ALTER TABLE `device`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `system_logs`
|
||||
--
|
||||
ALTER TABLE `system_logs`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `user`
|
||||
--
|
||||
ALTER TABLE `user`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `username` (`username`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `area`
|
||||
--
|
||||
ALTER TABLE `area`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `department`
|
||||
--
|
||||
ALTER TABLE `department`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `device`
|
||||
--
|
||||
ALTER TABLE `device`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `system_logs`
|
||||
--
|
||||
ALTER TABLE `system_logs`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `user`
|
||||
--
|
||||
ALTER TABLE `user`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=202;
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `auth_item_child`
|
||||
--
|
||||
ALTER TABLE `auth_item_child`
|
||||
ADD CONSTRAINT `auth_item_child_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `auth_item_child_ibfk_2` FOREIGN KEY (`child`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
23
assets/AreaAsset.php
Normal file
23
assets/AreaAsset.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace app\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
class AreaAsset extends AssetBundle {
|
||||
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/area.js'
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'app\assets\AppAsset',
|
||||
// 'yii\jui\JuiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
|
||||
}
|
92
controllers/AreaController.php
Normal file
92
controllers/AreaController.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use app\models\Area;
|
||||
use app\models\AreaSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* AreaController implements the CRUD actions for Area model.
|
||||
*/
|
||||
class AreaController extends Controller {
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
if (Yii::$app->user->isGuest)
|
||||
return $this->redirect(['/site/login']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors() {
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex() {
|
||||
$this->view->title = 'Khu vực';
|
||||
$searchModel = new AreaSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionView($id) {
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionCreate() {
|
||||
$model = new Area();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
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 actionDelete($id) {
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
protected function findModel($id) {
|
||||
if (($model = Area::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ namespace app\controllers;
|
|||
use Yii;
|
||||
use app\models\Department;
|
||||
use app\models\DepartmentSearch;
|
||||
use app\models\LogsDepartment;
|
||||
use app\models\SystemLogs;
|
||||
use app\models\common;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
@ -60,7 +60,7 @@ class DepartmentController extends Controller {
|
|||
return ["status" => false, "type" => "code"];
|
||||
|
||||
if ($model->create($data)) {
|
||||
Department::insertSystemLogs(["action" => "insert", "description" => "Thêm mới phòng ban: " . $data["Name"]]);
|
||||
common::insertSystemLogs(["action" => "insert", "description" => "Thêm mới phòng ban: " . $data["Name"], "type" => Yii::$app->controller->id]);
|
||||
return ["status" => true];
|
||||
} else
|
||||
return ["status" => false, "type" => "error"];
|
||||
|
@ -91,7 +91,7 @@ class DepartmentController extends Controller {
|
|||
$model->modified_at = time();
|
||||
if ($model->save()) {
|
||||
Department::updateAll(["pid" => $data["Code"]], ["pid" => $oldCode]);
|
||||
Department::insertSystemLogs(["action" => "update", "description" => "Chỉnh sửa phòng ban: " . $data["Name"]]);
|
||||
common::insertSystemLogs(["action" => "update", "description" => "Chỉnh sửa phòng ban: " . $data["Name"], "type" => Yii::$app->controller->id]);
|
||||
return ["status" => true];
|
||||
} else
|
||||
return ["status" => false, "type" => "error"];
|
||||
|
@ -181,7 +181,7 @@ class DepartmentController extends Controller {
|
|||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename="department_' . date("YmdHis") . '.xlsx"');
|
||||
header('Cache-Control: max-age=0');
|
||||
$objWriter->save('php://output');
|
||||
common::SaveViaTempFile($objWriter);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ class DepartmentController extends Controller {
|
|||
}
|
||||
$model = new Department();
|
||||
$model->multiCreate($datas);
|
||||
Department::insertSystemLogs(["action" => "import", "description" => "Nhập dữ liệu: " . count($post) . " phòng ban mới"]);
|
||||
common::insertSystemLogs(["action" => "import", "description" => "Nhập dữ liệu: " . count($post) . " phòng ban mới", "type" => Yii::$app->controller->id]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -226,11 +226,34 @@ class DepartmentController extends Controller {
|
|||
return [
|
||||
"title" => Html::tag("i", "", ["class" => "fa fa-file"]) . " Ghi nhận hệ thống",
|
||||
"form" => $this->renderPartial("logs", [
|
||||
"logs" => LogsDepartment::find()->orderBy(['time' => SORT_DESC])->limit(30)->all(),
|
||||
"logs" => SystemLogs::find()->andWhere(["type" => Yii::$app->controller->id])->orderBy(['time' => SORT_DESC])->limit(30)->all(),
|
||||
"userArray" => \app\models\User::userArray()
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionTree() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"title" => Html::tag("i", "", ["class" => "fa fa-sitemap"]) . " Cây thư mục",
|
||||
"form" => $this->renderPartial("tree", [
|
||||
"root" => Department::findOne(1)
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionTest() {
|
||||
$test = file_get_contents("http://192.168.2.119:2001/TestConnection", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode(["DeviceIP" => "192.168.1.201"])
|
||||
]
|
||||
]));
|
||||
return var_dump($test);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
92
controllers/DeviceController.php
Normal file
92
controllers/DeviceController.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use app\models\Device;
|
||||
use app\models\DeviceSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* DeviceController implements the CRUD actions for Device model.
|
||||
*/
|
||||
class DeviceController extends Controller {
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
if (Yii::$app->user->isGuest)
|
||||
return $this->redirect(['/site/login']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors() {
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex() {
|
||||
$this->view->title = 'Thiết bị';
|
||||
$searchModel = new DeviceSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionView($id) {
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionCreate() {
|
||||
$model = new Device();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
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 actionDelete($id) {
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
protected function findModel($id) {
|
||||
if (($model = Device::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
}
|
54
models/Area.php
Normal file
54
models/Area.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "area".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $code
|
||||
* @property int $pid
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property int $created_at
|
||||
* @property int $modified_at
|
||||
*/
|
||||
class Area extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'area';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['code', 'name'], 'required'],
|
||||
[['code', 'pid', 'created_at', 'modified_at'], 'integer'],
|
||||
[['description'], 'string'],
|
||||
[['name'], 'string', 'max' => 100],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'code' => 'Mã khu vực',
|
||||
'pid' => 'Khu vực cha',
|
||||
'name' => 'Tên khu vực',
|
||||
'description' => 'Chú thích',
|
||||
'created_at' => 'Thời gian tạo',
|
||||
'modified_at' => 'Thời gian sửa',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
74
models/AreaSearch.php
Normal file
74
models/AreaSearch.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use app\models\Area;
|
||||
|
||||
/**
|
||||
* AreaSearch represents the model behind the search form of `app\models\Area`.
|
||||
*/
|
||||
class AreaSearch extends Area
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'code', 'pid', 'created_at', 'modified_at'], 'integer'],
|
||||
[['name', 'description'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Area::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $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,
|
||||
'code' => $this->code,
|
||||
'pid' => $this->pid,
|
||||
'created_at' => $this->created_at,
|
||||
'modified_at' => $this->modified_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name])
|
||||
->andFilterWhere(['like', 'description', $this->description]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
|
@ -91,15 +91,10 @@ class Department extends \yii\db\ActiveRecord {
|
|||
self::deleteDepartment($value->id);
|
||||
}
|
||||
$model->delete();
|
||||
self::insertSystemLogs(["action" => "delete", "description" => "Xóa phòng ban: " . $model->name]);
|
||||
common::insertSystemLogs(["action" => "delete", "description" => "Xóa phòng ban: " . $model->name, "type" => "department"]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function insertSystemLogs($data) {
|
||||
$model = new LogsDepartment();
|
||||
return $model->create($data);
|
||||
}
|
||||
|
||||
public function checkStatusImport($data) {
|
||||
if ($this->findOne(["code" => $data["A"]]))
|
||||
return ["status" => false, "description" => "Mã phòng ban đã tồn tại"];
|
||||
|
|
61
models/Device.php
Normal file
61
models/Device.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "device".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $serial
|
||||
* @property string $ip_address
|
||||
* @property int $status
|
||||
* @property int $type
|
||||
* @property int $area_id
|
||||
* @property int $created_at
|
||||
* @property int $modified_at
|
||||
*/
|
||||
class Device extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'device';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'ip_address', 'status', 'type', 'area_id'], 'required'],
|
||||
[['status', 'type', 'area_id', 'created_at', 'modified_at'], 'integer'],
|
||||
[['name'], 'string', 'max' => 100],
|
||||
[['serial'], 'string', 'max' => 50],
|
||||
[['ip_address'], 'string', 'max' => 20],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Name',
|
||||
'serial' => 'Serial',
|
||||
'ip_address' => 'Ip Address',
|
||||
'status' => 'Status',
|
||||
'type' => 'Type',
|
||||
'area_id' => 'Area ID',
|
||||
'created_at' => 'Created At',
|
||||
'modified_at' => 'Modified At',
|
||||
];
|
||||
}
|
||||
}
|
76
models/DeviceSearch.php
Normal file
76
models/DeviceSearch.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use app\models\Device;
|
||||
|
||||
/**
|
||||
* DeviceSearch represents the model behind the search form of `app\models\Device`.
|
||||
*/
|
||||
class DeviceSearch extends Device
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'status', 'type', 'area_id', 'created_at', 'modified_at'], 'integer'],
|
||||
[['name', 'serial', 'ip_address'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Device::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $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,
|
||||
'status' => $this->status,
|
||||
'type' => $this->type,
|
||||
'area_id' => $this->area_id,
|
||||
'created_at' => $this->created_at,
|
||||
'modified_at' => $this->modified_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name])
|
||||
->andFilterWhere(['like', 'serial', $this->serial])
|
||||
->andFilterWhere(['like', 'ip_address', $this->ip_address]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
|
@ -5,21 +5,22 @@ namespace app\models;
|
|||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "logs_department".
|
||||
* This is the model class for table "system_logs".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $time
|
||||
* @property string $action
|
||||
* @property string $description
|
||||
* @property string $type
|
||||
*/
|
||||
class LogsDepartment extends \yii\db\ActiveRecord {
|
||||
class SystemLogs extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'logs_department';
|
||||
return 'system_logs';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,10 +28,11 @@ class LogsDepartment extends \yii\db\ActiveRecord {
|
|||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['user_id', 'time', 'action', 'description'], 'required'],
|
||||
[['user_id', 'time', 'action', 'description', 'type'], 'required'],
|
||||
[['user_id', 'time'], 'integer'],
|
||||
[['description'], 'string'],
|
||||
[['action'], 'string', 'max' => 10],
|
||||
[['type'], 'string', 'max' => 100],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -44,6 +46,7 @@ class LogsDepartment extends \yii\db\ActiveRecord {
|
|||
'time' => 'Time',
|
||||
'action' => 'Action',
|
||||
'description' => 'Description',
|
||||
'type' => 'Type',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -52,7 +55,8 @@ class LogsDepartment extends \yii\db\ActiveRecord {
|
|||
'user_id' => Yii::$app->user->id,
|
||||
'time' => time(),
|
||||
'action' => $data['action'],
|
||||
'description' => $data['description']
|
||||
'description' => $data['description'],
|
||||
'type' => $data['type']
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
|
@ -171,4 +171,16 @@ class common extends \yii\db\ActiveRecord {
|
|||
return $visible;
|
||||
}
|
||||
|
||||
public static function SaveViaTempFile($objWriter) {
|
||||
$filePath = rand(0, getrandmax()) . rand(0, getrandmax()) . ".tmp";
|
||||
$objWriter->save($filePath);
|
||||
readfile($filePath);
|
||||
unlink($filePath);
|
||||
}
|
||||
|
||||
public static function insertSystemLogs($data) {
|
||||
$model = new SystemLogs();
|
||||
return $model->create($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
509
traffic.sql
509
traffic.sql
|
@ -1,509 +0,0 @@
|
|||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.9.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Oct 06, 2020 at 06:46 AM
|
||||
-- Server version: 10.4.8-MariaDB
|
||||
-- PHP Version: 7.1.33
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET AUTOCOMMIT = 0;
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `traffic`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `area`
|
||||
--
|
||||
|
||||
CREATE TABLE `area` (
|
||||
`id` int(11) NOT NULL,
|
||||
`pid` int(11) NOT NULL DEFAULT 0,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`status` int(11) NOT NULL DEFAULT 1,
|
||||
`created_at` int(11) NOT NULL,
|
||||
`modified_at` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `auth_assignment`
|
||||
--
|
||||
|
||||
CREATE TABLE `auth_assignment` (
|
||||
`item_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`user_id` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `auth_assignment`
|
||||
--
|
||||
|
||||
INSERT INTO `auth_assignment` (`item_name`, `user_id`, `created_at`) VALUES
|
||||
('administrator', '1', 1569900053);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `auth_item`
|
||||
--
|
||||
|
||||
CREATE TABLE `auth_item` (
|
||||
`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`type` smallint(6) NOT NULL,
|
||||
`description` text COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`rule_name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`data` blob DEFAULT NULL,
|
||||
`created_at` int(11) DEFAULT NULL,
|
||||
`updated_at` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `auth_item`
|
||||
--
|
||||
|
||||
INSERT INTO `auth_item` (`name`, `type`, `description`, `rule_name`, `data`, `created_at`, `updated_at`) VALUES
|
||||
('administrator', 1, 'Administrator', NULL, NULL, 1535011160, 1535011160);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `auth_item_child`
|
||||
--
|
||||
|
||||
CREATE TABLE `auth_item_child` (
|
||||
`parent` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`child` varchar(64) COLLATE utf8_unicode_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `auth_rule`
|
||||
--
|
||||
|
||||
CREATE TABLE `auth_rule` (
|
||||
`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`data` blob DEFAULT NULL,
|
||||
`created_at` int(11) DEFAULT NULL,
|
||||
`updated_at` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `camera`
|
||||
--
|
||||
|
||||
CREATE TABLE `camera` (
|
||||
`id` int(11) NOT NULL,
|
||||
`gate` int(11) NOT NULL,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`type` varchar(5) NOT NULL,
|
||||
`stream_url` text DEFAULT NULL,
|
||||
`minWidth` int(11) NOT NULL DEFAULT 0,
|
||||
`maxWidth` int(11) NOT NULL DEFAULT 0,
|
||||
`minHeight` int(11) NOT NULL DEFAULT 0,
|
||||
`maxHeight` int(11) NOT NULL DEFAULT 0,
|
||||
`scaleFactor` float NOT NULL DEFAULT 0,
|
||||
`minNeighbors` int(11) NOT NULL DEFAULT 0,
|
||||
`status` int(11) NOT NULL DEFAULT 1,
|
||||
`isRecognizeCamera` int(11) NOT NULL DEFAULT 1,
|
||||
`isLongPlate` int(11) NOT NULL DEFAULT 0,
|
||||
`stt` int(11) NOT NULL,
|
||||
`roi_config` text DEFAULT NULL,
|
||||
`created_at` int(11) NOT NULL,
|
||||
`modified_at` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `card`
|
||||
--
|
||||
|
||||
CREATE TABLE `card` (
|
||||
`id` int(11) NOT NULL,
|
||||
`card_id` int(11) NOT NULL DEFAULT 0,
|
||||
`code` varchar(30) NOT NULL,
|
||||
`card_group` int(11) NOT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`name` varchar(100) DEFAULT NULL,
|
||||
`department` varchar(100) DEFAULT NULL,
|
||||
`phone` varchar(20) DEFAULT NULL,
|
||||
`plate` varchar(20) DEFAULT NULL,
|
||||
`brand` varchar(50) DEFAULT NULL,
|
||||
`address` text DEFAULT NULL,
|
||||
`ngay_dang_ky` int(11) NOT NULL DEFAULT 0,
|
||||
`ngay_phat_the` int(11) NOT NULL DEFAULT 0,
|
||||
`ngay_hoat_dong` int(11) NOT NULL DEFAULT 0,
|
||||
`ngay_het_han` int(11) NOT NULL DEFAULT 0,
|
||||
`status` int(11) NOT NULL DEFAULT 1,
|
||||
`created_at` int(11) NOT NULL DEFAULT 0,
|
||||
`modified_at` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `card_group`
|
||||
--
|
||||
|
||||
CREATE TABLE `card_group` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`card_type` int(11) NOT NULL DEFAULT 1,
|
||||
`vehicle_type` int(11) NOT NULL DEFAULT 1,
|
||||
`auto_open_door` int(11) NOT NULL DEFAULT 0,
|
||||
`cost_config` text DEFAULT NULL,
|
||||
`created_at` int(11) NOT NULL DEFAULT 0,
|
||||
`modified_at` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `config`
|
||||
--
|
||||
|
||||
CREATE TABLE `config` (
|
||||
`id` int(11) NOT NULL,
|
||||
`mac_address` varchar(30) NOT NULL,
|
||||
`active` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `gate`
|
||||
--
|
||||
|
||||
CREATE TABLE `gate` (
|
||||
`id` int(11) NOT NULL,
|
||||
`area` int(11) NOT NULL,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`status` int(11) NOT NULL DEFAULT 1,
|
||||
`user_id` int(11) NOT NULL DEFAULT 0,
|
||||
`api_config` text DEFAULT NULL,
|
||||
`cascade_config` text DEFAULT NULL,
|
||||
`lane_config` text DEFAULT NULL,
|
||||
`created_at` int(11) NOT NULL,
|
||||
`modified_at` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `logs`
|
||||
--
|
||||
|
||||
CREATE TABLE `logs` (
|
||||
`id` int(11) NOT NULL,
|
||||
`card_id` int(11) NOT NULL,
|
||||
`plate_in` varchar(20) DEFAULT NULL,
|
||||
`plate_image_in` text DEFAULT NULL,
|
||||
`frame_image_in` text DEFAULT NULL,
|
||||
`face_image_in` text DEFAULT NULL,
|
||||
`name_in` varchar(100) DEFAULT NULL,
|
||||
`time_in` int(11) NOT NULL,
|
||||
`camera_in` int(11) NOT NULL DEFAULT 0,
|
||||
`mod_in` int(11) NOT NULL DEFAULT 0,
|
||||
`plate_out` varchar(20) DEFAULT NULL,
|
||||
`plate_image_out` text DEFAULT NULL,
|
||||
`frame_image_out` text DEFAULT NULL,
|
||||
`face_image_out` text NOT NULL,
|
||||
`name_out` varchar(100) DEFAULT NULL,
|
||||
`time_out` int(11) NOT NULL DEFAULT 0,
|
||||
`camera_out` int(11) NOT NULL DEFAULT 0,
|
||||
`mod_out` int(11) NOT NULL DEFAULT 0,
|
||||
`logs_number` int(11) NOT NULL DEFAULT 0,
|
||||
`soft_delete` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `user`
|
||||
--
|
||||
|
||||
CREATE TABLE `user` (
|
||||
`id` int(11) NOT NULL,
|
||||
`first_name` varchar(250) NOT NULL,
|
||||
`last_name` varchar(250) DEFAULT NULL,
|
||||
`phone_number` varchar(30) DEFAULT NULL,
|
||||
`username` varchar(250) NOT NULL,
|
||||
`email` varchar(500) DEFAULT NULL,
|
||||
`password` varchar(250) NOT NULL,
|
||||
`authKey` varchar(250) DEFAULT NULL,
|
||||
`password_reset_token` varchar(250) DEFAULT NULL,
|
||||
`user_image` varchar(500) DEFAULT NULL,
|
||||
`quota` int(11) NOT NULL DEFAULT 2
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Dumping data for table `user`
|
||||
--
|
||||
|
||||
INSERT INTO `user` (`id`, `first_name`, `last_name`, `phone_number`, `username`, `email`, `password`, `authKey`, `password_reset_token`, `user_image`, `quota`) VALUES
|
||||
(1, 'Administrator', '', '12313', 'admin', 'admin@bitraffic.vn', 'ceea23519f6f86ad67e9f798bf8002cb', NULL, NULL, '', 2);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `vip_logs`
|
||||
--
|
||||
|
||||
CREATE TABLE `vip_logs` (
|
||||
`id` int(11) NOT NULL,
|
||||
`vehicle_id` int(11) NOT NULL,
|
||||
`plate_in` varchar(20) DEFAULT NULL,
|
||||
`plate_image_in` text DEFAULT NULL,
|
||||
`vehicle_image_in` text DEFAULT NULL,
|
||||
`time_in` int(11) NOT NULL DEFAULT 0,
|
||||
`gate_in` int(11) NOT NULL DEFAULT 0,
|
||||
`plate_out` varchar(20) DEFAULT NULL,
|
||||
`plate_image_out` text DEFAULT NULL,
|
||||
`vehicle_image_out` text DEFAULT NULL,
|
||||
`time_out` int(11) NOT NULL DEFAULT 0,
|
||||
`gate_out` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `vip_logs_other`
|
||||
--
|
||||
|
||||
CREATE TABLE `vip_logs_other` (
|
||||
`id` int(11) NOT NULL,
|
||||
`plate` varchar(20) DEFAULT NULL,
|
||||
`plate_image_in` text DEFAULT NULL,
|
||||
`vehicle_image_in` text DEFAULT NULL,
|
||||
`time_in` int(11) NOT NULL DEFAULT 0,
|
||||
`gate_in` int(11) NOT NULL DEFAULT 0,
|
||||
`plate_image_out` text DEFAULT NULL,
|
||||
`vehicle_image_out` text DEFAULT NULL,
|
||||
`time_out` int(11) NOT NULL DEFAULT 0,
|
||||
`gate_out` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `vip_vehicle`
|
||||
--
|
||||
|
||||
CREATE TABLE `vip_vehicle` (
|
||||
`id` int(11) NOT NULL,
|
||||
`plate` varchar(20) DEFAULT NULL,
|
||||
`chuxe` varchar(100) DEFAULT NULL,
|
||||
`loaixe` varchar(100) DEFAULT NULL,
|
||||
`donvi` varchar(100) DEFAULT NULL,
|
||||
`dienthoai` varchar(20) DEFAULT NULL,
|
||||
`diachi` text DEFAULT NULL,
|
||||
`status` int(11) NOT NULL DEFAULT 1,
|
||||
`created_at` int(11) NOT NULL,
|
||||
`modified_at` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `area`
|
||||
--
|
||||
ALTER TABLE `area`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `auth_assignment`
|
||||
--
|
||||
ALTER TABLE `auth_assignment`
|
||||
ADD PRIMARY KEY (`item_name`,`user_id`),
|
||||
ADD KEY `auth_assignment_user_id_idx` (`user_id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `auth_item`
|
||||
--
|
||||
ALTER TABLE `auth_item`
|
||||
ADD PRIMARY KEY (`name`),
|
||||
ADD KEY `rule_name` (`rule_name`),
|
||||
ADD KEY `idx-auth_item-type` (`type`);
|
||||
|
||||
--
|
||||
-- Indexes for table `auth_item_child`
|
||||
--
|
||||
ALTER TABLE `auth_item_child`
|
||||
ADD PRIMARY KEY (`parent`,`child`),
|
||||
ADD KEY `child` (`child`);
|
||||
|
||||
--
|
||||
-- Indexes for table `auth_rule`
|
||||
--
|
||||
ALTER TABLE `auth_rule`
|
||||
ADD PRIMARY KEY (`name`);
|
||||
|
||||
--
|
||||
-- Indexes for table `camera`
|
||||
--
|
||||
ALTER TABLE `camera`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `card`
|
||||
--
|
||||
ALTER TABLE `card`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `card_group`
|
||||
--
|
||||
ALTER TABLE `card_group`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `config`
|
||||
--
|
||||
ALTER TABLE `config`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `gate`
|
||||
--
|
||||
ALTER TABLE `gate`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `logs`
|
||||
--
|
||||
ALTER TABLE `logs`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `user`
|
||||
--
|
||||
ALTER TABLE `user`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `username` (`username`);
|
||||
|
||||
--
|
||||
-- Indexes for table `vip_logs`
|
||||
--
|
||||
ALTER TABLE `vip_logs`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `vip_logs_other`
|
||||
--
|
||||
ALTER TABLE `vip_logs_other`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `vip_vehicle`
|
||||
--
|
||||
ALTER TABLE `vip_vehicle`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `area`
|
||||
--
|
||||
ALTER TABLE `area`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `camera`
|
||||
--
|
||||
ALTER TABLE `camera`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `card`
|
||||
--
|
||||
ALTER TABLE `card`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `card_group`
|
||||
--
|
||||
ALTER TABLE `card_group`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `config`
|
||||
--
|
||||
ALTER TABLE `config`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `gate`
|
||||
--
|
||||
ALTER TABLE `gate`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `logs`
|
||||
--
|
||||
ALTER TABLE `logs`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `user`
|
||||
--
|
||||
ALTER TABLE `user`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=202;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `vip_logs`
|
||||
--
|
||||
ALTER TABLE `vip_logs`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `vip_logs_other`
|
||||
--
|
||||
ALTER TABLE `vip_logs_other`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `vip_vehicle`
|
||||
--
|
||||
ALTER TABLE `vip_vehicle`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `auth_item_child`
|
||||
--
|
||||
ALTER TABLE `auth_item_child`
|
||||
ADD CONSTRAINT `auth_item_child_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `auth_item_child_ibfk_2` FOREIGN KEY (`child`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
|
@ -19,30 +19,30 @@ use yii\widgets\ActiveForm;
|
|||
|
||||
<nav class="navbar navbar-static-top" role="navigation">
|
||||
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<ul class="nav navbar-nav" style="font-size: 20px;">
|
||||
<li class="<?php if (in_array($this->context->id, ['department'])) echo "active"; ?>">
|
||||
<a href="<?php echo \yii\helpers\Url::to(['/department']); ?>">
|
||||
<i class="fa fa-users"></i> Nhân sự
|
||||
Nhân sự
|
||||
</a>
|
||||
</li>
|
||||
<li class="<?php if (in_array($this->context->id, ['area', 'device'])) echo "active"; ?>">
|
||||
<a href="<?php echo \yii\helpers\Url::to(['/device']); ?>">
|
||||
Thiết bị
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-database"></i> Thiết bị
|
||||
Kiểm soát truy cập
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-check-square"></i> Kiểm soát truy cập
|
||||
Báo cáo
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-bar-chart"></i> Báo cáo
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-cogs"></i> Hệ thống
|
||||
Hệ thống
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -2,13 +2,6 @@
|
|||
<section class="sidebar">
|
||||
<br>
|
||||
<?php
|
||||
if (in_array($this->context->id, ['department'])) {
|
||||
$items = [
|
||||
['label' => 'Phòng ban', 'url' => ['/department'], 'icon' => 'building'],
|
||||
['label' => 'Nhân viên', 'url' => ['/dashboard'], 'icon' => 'users'],
|
||||
['label' => 'Đăng ký thẻ', 'url' => ['/dashboard'], 'icon' => 'credit-card']
|
||||
];
|
||||
} else {
|
||||
$items = [
|
||||
['label' => 'Bảng điều khiển', 'url' => ['/dashboard'], 'icon' => 'dashboard'],
|
||||
[
|
||||
|
@ -20,6 +13,19 @@
|
|||
],
|
||||
['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
|
||||
];
|
||||
if (in_array($this->context->id, ['department'])) {
|
||||
$items = [
|
||||
['label' => 'Phòng ban', 'url' => ['/department'], 'icon' => 'building'],
|
||||
['label' => 'Nhân viên', 'url' => ['/dashboard'], 'icon' => 'users'],
|
||||
['label' => 'Đăng ký thẻ', 'url' => ['/dashboard'], 'icon' => 'credit-card']
|
||||
];
|
||||
}
|
||||
if (in_array($this->context->id, ['area', 'device'])) {
|
||||
$items = [
|
||||
['label' => 'Khu vực', 'url' => ['/area'], 'icon' => 'building'],
|
||||
['label' => 'Thiết bị', 'url' => ['/device'], 'icon' => 'database'],
|
||||
['label' => 'Tìm kiếm thiết bị', 'url' => ['/dashboard'], 'icon' => 'search']
|
||||
];
|
||||
}
|
||||
?>
|
||||
<?=
|
||||
|
|
33
views/area/_form.php
Normal file
33
views/area/_form.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model app\models\Area */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="area-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'code')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'pid')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>
|
||||
|
||||
<?= $form->field($model, 'created_at')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'modified_at')->textInput() ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
42
views/area/_search.php
Normal file
42
views/area/_search.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model app\models\AreaSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="area-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['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') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'modified_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
21
views/area/create.php
Normal file
21
views/area/create.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model app\models\Area */
|
||||
|
||||
$this->title = 'Create Area';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Areas', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="area-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
41
views/area/index.php
Normal file
41
views/area/index.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\Pjax;
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel app\models\AreaSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Areas';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="area-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<?php Pjax::begin(); ?>
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Create Area', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= 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'],
|
||||
],
|
||||
]); ?>
|
||||
<?php Pjax::end(); ?>
|
||||
</div>
|
68
views/area/index.tpl
Normal file
68
views/area/index.tpl
Normal file
|
@ -0,0 +1,68 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{use class="yii\widgets\Pjax" type="block"}
|
||||
{use class="app\assets\AreaAsset"}
|
||||
{AreaAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<div class="area-index">
|
||||
<div class="" style="font-size: 15px;">
|
||||
<label class="action-button" onclick="common.form(this, '');" data-href="{Url::to(['tree'])}">
|
||||
<i class="fa fa-sitemap fa-1-5x"></i> Cây thư mục
|
||||
</label>
|
||||
<label class="action-button" onclick="common.form(this, 'department');" data-href="{Url::to(['create'])}">
|
||||
<i class="fa fa-plus-square fa-1-5x"></i> Thêm
|
||||
</label>
|
||||
<label class="action-button" onclick="_form(this);" data-href="{Url::to(['update'])}">
|
||||
<i class="fa fa-edit fa-1-5x"></i> Tùy chỉnh
|
||||
</label>
|
||||
<label class="action-button" onclick="_delete(this);" data-href="{Url::to(['delete'])}">
|
||||
<i class="fa fa-trash fa-1-5x"></i> Xóa
|
||||
</label>
|
||||
<label class="action-button" onclick="_export(this);" data-href="{Url::to(['export'])}">
|
||||
<i class="fa fa-download fa-1-5x"></i> Xuất
|
||||
</label>
|
||||
<label class="action-button" onclick="_logs(this);" data-href="{Url::to(['logs'])}">
|
||||
<i class="fa fa-file fa-1-5x"></i> Ghi nhận hệ thống
|
||||
</label>
|
||||
</div>
|
||||
{Pjax id="area-list"}
|
||||
{GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'layout'=> \app\helpers\DepartmentGrid::getLayout(),
|
||||
'tableOptions' => [
|
||||
'class' => 'table table-striped table-bordered table-hover',
|
||||
'style' => 'background:#fff;min-width:700px;'
|
||||
],
|
||||
'rowOptions' => \app\helpers\DepartmentGrid::rows(),
|
||||
'columns' => [
|
||||
[
|
||||
'class' => 'yii\grid\SerialColumn',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%']
|
||||
],
|
||||
[
|
||||
'header' => "<input type='checkbox' value='0' class='checkbox-department' id='checkall-department'>",
|
||||
'format' => 'raw',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
|
||||
'value' => \app\helpers\DepartmentGrid::checkbox()
|
||||
],
|
||||
'code',
|
||||
'pid',
|
||||
'name',
|
||||
'description:ntext',
|
||||
[
|
||||
'attribute' => 'created_at',
|
||||
'value' => \app\helpers\DepartmentGrid::createdAt()
|
||||
],
|
||||
[
|
||||
'attribute' => 'modified_at',
|
||||
'value' => \app\helpers\DepartmentGrid::modifiedAt()
|
||||
]
|
||||
]
|
||||
])}
|
||||
{/Pjax}
|
||||
</div>
|
||||
{/block}
|
21
views/area/update.php
Normal file
21
views/area/update.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model app\models\Area */
|
||||
|
||||
$this->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';
|
||||
?>
|
||||
<div class="area-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
41
views/area/view.php
Normal file
41
views/area/view.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model app\models\Area */
|
||||
|
||||
$this->title = $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Areas', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="area-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= 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',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
'code',
|
||||
'pid',
|
||||
'name',
|
||||
'description:ntext',
|
||||
'created_at',
|
||||
'modified_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
|
@ -20,14 +20,14 @@
|
|||
<div class="form-group" id="code">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Mã phòng ban <i class="text-red">*</i></div>
|
||||
<input type="number" class="form-control" value="{$model->code|default:""}" name="Code">
|
||||
<input type="number" class="form-control" value="{$model->code|default:""}" name="Code" {if $model->code==1}disabled=""{/if}>
|
||||
</div>
|
||||
<span class="help-block hidden"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Trực thuộc <i class="text-red">*</i></div>
|
||||
<select class="form-control" name="Pid" id="Pid">
|
||||
<select class="form-control" name="Pid" id="Pid" {if $model->code==1}disabled=""{/if}>
|
||||
{html_options options=$departmentArray selected=$model->pid|default:1}
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -6,27 +6,27 @@
|
|||
{DepartmentAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<div class="department-index">
|
||||
<div class="">
|
||||
<label class="action-button">
|
||||
<i class="fa fa-sitemap"></i> Cây thư mục
|
||||
<div class="" style="font-size: 15px;">
|
||||
<label class="action-button" onclick="common.form(this, '');" data-href="{Url::to(['tree'])}">
|
||||
<i class="fa fa-sitemap fa-1-5x"></i> Cây thư mục
|
||||
</label>
|
||||
<label class="action-button" onclick="common.form(this, 'department');" data-href="{Url::to(['create'])}">
|
||||
<i class="fa fa-plus-square"></i> Thêm
|
||||
<i class="fa fa-plus-square fa-1-5x"></i> Thêm
|
||||
</label>
|
||||
<label class="action-button" onclick="_form(this);" data-href="{Url::to(['update'])}">
|
||||
<i class="fa fa-edit"></i> Tùy chỉnh
|
||||
<i class="fa fa-edit fa-1-5x"></i> Tùy chỉnh
|
||||
</label>
|
||||
<label class="action-button" onclick="_delete(this);" data-href="{Url::to(['delete'])}">
|
||||
<i class="fa fa-trash"></i> Xóa
|
||||
<i class="fa fa-trash fa-1-5x"></i> Xóa
|
||||
</label>
|
||||
<label class="action-button" onclick="$('#file').trigger('click');">
|
||||
<i class="fa fa-upload"></i> Nhập
|
||||
<i class="fa fa-upload fa-1-5x"></i> Nhập
|
||||
</label>
|
||||
<label class="action-button" onclick="_export(this);" data-href="{Url::to(['export'])}">
|
||||
<i class="fa fa-download"></i> Xuất
|
||||
<i class="fa fa-download fa-1-5x"></i> Xuất
|
||||
</label>
|
||||
<label class="action-button" onclick="_logs(this);" data-href="{Url::to(['logs'])}">
|
||||
<i class="fa fa-file"></i> Ghi nhận hệ thống
|
||||
<i class="fa fa-file fa-1-5x"></i> Ghi nhận hệ thống
|
||||
</label>
|
||||
</div>
|
||||
<div class="hidden">
|
||||
|
|
7
views/department/tree.tpl
Normal file
7
views/department/tree.tpl
Normal 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\Department::widget(["pid"=>1])}
|
||||
</div>
|
||||
</div>
|
73
views/device/index.tpl
Normal file
73
views/device/index.tpl
Normal file
|
@ -0,0 +1,73 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{use class="yii\widgets\Pjax" type="block"}
|
||||
{*use class="app\assets\DepartmentAsset"}
|
||||
{DepartmentAsset::register($this)|void*}
|
||||
{block name='content'}
|
||||
<div class="device-index">
|
||||
<div class="" style="font-size: 15px;">
|
||||
<label class="action-button" onclick="common.form(this, '');" data-href="{Url::to(['tree'])}">
|
||||
<i class="fa fa-sitemap fa-1-5x"></i> Cây thư mục
|
||||
</label>
|
||||
<label class="action-button" onclick="common.form(this, 'department');" data-href="{Url::to(['create'])}">
|
||||
<i class="fa fa-plus-square fa-1-5x"></i> Thêm
|
||||
</label>
|
||||
<label class="action-button" onclick="_form(this);" data-href="{Url::to(['update'])}">
|
||||
<i class="fa fa-edit fa-1-5x"></i> Tùy chỉnh
|
||||
</label>
|
||||
<label class="action-button" onclick="_delete(this);" data-href="{Url::to(['delete'])}">
|
||||
<i class="fa fa-trash fa-1-5x"></i> Xóa
|
||||
</label>
|
||||
<label class="action-button" onclick="$('#file').trigger('click');">
|
||||
<i class="fa fa-upload fa-1-5x"></i> Nhập
|
||||
</label>
|
||||
<label class="action-button" onclick="_export(this);" data-href="{Url::to(['export'])}">
|
||||
<i class="fa fa-download fa-1-5x"></i> Xuất
|
||||
</label>
|
||||
<label class="action-button" onclick="_logs(this);" data-href="{Url::to(['logs'])}">
|
||||
<i class="fa fa-file fa-1-5x"></i> Ghi nhận hệ thống
|
||||
</label>
|
||||
</div>
|
||||
<div class="hidden">
|
||||
<input type="file" name="file" id="file">
|
||||
<input type="hidden" value="{Url::to(['upload'])}" name="upload_file_url">
|
||||
</div>
|
||||
{Pjax id="device-list"}
|
||||
{GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'layout'=> \app\helpers\DepartmentGrid::getLayout(),
|
||||
'tableOptions' => [
|
||||
'class' => 'table table-striped table-bordered table-hover',
|
||||
'style' => 'background:#fff;min-width:700px;'
|
||||
],
|
||||
'rowOptions' => \app\helpers\DepartmentGrid::rows(),
|
||||
'columns' => [
|
||||
[
|
||||
'class' => 'yii\grid\SerialColumn',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%']
|
||||
],
|
||||
[
|
||||
'header' => "<input type='checkbox' value='0' class='checkbox-department' id='checkall-department'>",
|
||||
'format' => 'raw',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
|
||||
'value' => \app\helpers\DepartmentGrid::checkbox()
|
||||
],
|
||||
'name',
|
||||
'ip_address',
|
||||
[
|
||||
'attribute' => 'created_at',
|
||||
'value' => \app\helpers\DepartmentGrid::createdAt()
|
||||
],
|
||||
[
|
||||
'attribute' => 'modified_at',
|
||||
'value' => \app\helpers\DepartmentGrid::modifiedAt()
|
||||
]
|
||||
]
|
||||
])}
|
||||
{/Pjax}
|
||||
</div>
|
||||
{/block}
|
|
@ -245,6 +245,7 @@ table > tbody > tr.success >td>a {
|
|||
margin: 0;
|
||||
cursor: pointer;
|
||||
font-weight: inherit;
|
||||
border: 1px solid #ecf0f5;
|
||||
}
|
||||
.action-button:hover{
|
||||
font-weight: bold;
|
||||
|
@ -255,3 +256,6 @@ table > tbody > tr.success >td>a {
|
|||
padding: 10px;
|
||||
background: #b2d7ec;
|
||||
}
|
||||
.fa-1-5x {
|
||||
font-size: 1.3em !important;
|
||||
}
|
199
web/js/area.js
Normal file
199
web/js/area.js
Normal file
|
@ -0,0 +1,199 @@
|
|||
$(function () {
|
||||
common.checkboxInit("area");
|
||||
});
|
||||
|
||||
function validate() {
|
||||
var error = 0;
|
||||
var Name = $("input[name='Name']").val();
|
||||
if (Name === "") {
|
||||
common.error("name", "Tên phòng ban không được để trống");
|
||||
error++;
|
||||
} else {
|
||||
common.success("name");
|
||||
}
|
||||
|
||||
var Code = $("input[name='Code']").val();
|
||||
if (Code === "") {
|
||||
common.error("code", "Mã phòng ban không được để trống");
|
||||
error++;
|
||||
} else {
|
||||
common.success("code");
|
||||
}
|
||||
return error == 0 ? true : false;
|
||||
}
|
||||
|
||||
function save(e) {
|
||||
if (validate()) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr('data-href'),
|
||||
type: 'POST',
|
||||
data: {
|
||||
Name: $("input[name='Name']").val(),
|
||||
Code: $("input[name='Code']").val(),
|
||||
Pid: $("select[name='Pid']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
if (data.status) {
|
||||
notification.success("Đã lưu thông tin", 1000);
|
||||
$.pjax.reload({container: '#department-list'});
|
||||
$("#department-list").on('pjax:success', function () {
|
||||
common.checkboxInit("department");
|
||||
});
|
||||
$("#myModal").modal("hide");
|
||||
} else {
|
||||
if (data.type === "code") {
|
||||
common.error("code", "Mã phòng ban đã tồn tại");
|
||||
} else {
|
||||
notification.danger("Có lỗi xảy ra, không lưu được dữ liệu!", 1000);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function _form(e) {
|
||||
var lists = [];
|
||||
$.each($("input[name='checkbox-department']:checked"), function () {
|
||||
lists.push($(this).val());
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
alert("Vui lòng lựa chọn đối tượng để thay đổi!");
|
||||
return;
|
||||
}
|
||||
if (lists.length > 1) {
|
||||
alert("Tác vụ này không thể lựa chọn nhiều hơn một đối tượng!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr('data-href') + "?id=" + lists[0],
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
common.modalOpen(data.form, false, data.title);
|
||||
$('#Pid').select2();
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _delete(e) {
|
||||
var lists = [];
|
||||
$.each($("input[name='checkbox-department']:checked"), function () {
|
||||
lists.push($(this).val());
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
alert("Vui lòng lựa chọn đối tượng để xóa!");
|
||||
return;
|
||||
}
|
||||
if (lists.length == 1 && lists[0] === "1") {
|
||||
alert("Danh mục gốc không thể xóa!");
|
||||
return;
|
||||
}
|
||||
if (confirm("Bạn có chắc chắn muốn xóa các đối tượng đã lựa chọn không?")) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr('data-href'),
|
||||
type: 'POST',
|
||||
data: {
|
||||
lists: lists
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
notification.danger("Đã xóa dữ liệu", 1000);
|
||||
$.pjax.reload({container: '#department-list'});
|
||||
$("#department-list").on('pjax:success', function () {
|
||||
common.checkboxInit("department");
|
||||
});
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function _export(e) {
|
||||
window.location = $(e).attr("data-href");
|
||||
}
|
||||
|
||||
function btnUpload(mUrl, className, extension, fileSize) {
|
||||
var fData = {
|
||||
UploadFile: true,
|
||||
Name: className
|
||||
};
|
||||
fData[common.csrfParam] = common.csrf;
|
||||
new afuButton({
|
||||
uploadURI: mUrl,
|
||||
formData: fData,
|
||||
wrap: {
|
||||
tagName: 'div',
|
||||
classes: ''
|
||||
},
|
||||
fileExtension: extension,
|
||||
fileSizeLimit: fileSize,
|
||||
classes: 'btn btn-default file-paperclip-' + className,
|
||||
fakeInputContent: '<span class=\'fa fa-upload\'></span> Nhập dữ liệu',
|
||||
onUploaded: function (data) {
|
||||
data = JSON.parse(data);
|
||||
common.modalOpen(data.form, true, data.title);
|
||||
common.uploadBlock(false);
|
||||
common.checkboxInit("department-import");
|
||||
}
|
||||
}).addInstance('file' + className);
|
||||
$(".file-paperclip-" + className).closest("div").attr("style", "display:inline-block;");
|
||||
}
|
||||
|
||||
function _import(e) {
|
||||
var lists = [];
|
||||
$.each($("input[name='checkbox-department-import']:checked"), function () {
|
||||
lists.push($(this).val());
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
alert("Vui lòng lựa chọn đối tượng để nhập!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr('data-href'),
|
||||
type: 'POST',
|
||||
data: {
|
||||
lists: lists
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
window.location.reload(true);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _logs(e) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr('data-href'),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
common.modalOpen(data.form, true, data.title);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
|
@ -239,6 +239,17 @@ common.checkboxInit = function (id) {
|
|||
}
|
||||
});
|
||||
};
|
||||
common.tree = function (e) {
|
||||
var stt = $(e).attr("data-stt");
|
||||
if (stt === "true") {
|
||||
$(e).removeClass("fa-minus-square-o").addClass("fa-plus-square-o").attr("data-stt", "false");
|
||||
$("#sub-tree-" + $(e).attr("data")).addClass("hidden");
|
||||
} else {
|
||||
$(e).removeClass("fa-plus-square-o").addClass("fa-minus-square-o").attr("data-stt", "true");
|
||||
$("#sub-tree-" + $(e).attr("data")).removeClass("hidden");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* =========================
|
||||
*/
|
||||
|
|
22
widgets/Department.php
Normal file
22
widgets/Department.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?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()
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
9
widgets/views/department.tpl
Normal file
9
widgets/views/department.tpl
Normal file
|
@ -0,0 +1,9 @@
|
|||
{foreach from=$lists item=l}
|
||||
<div style="cursor: pointer;">
|
||||
<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])}
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
Loading…
Reference in New Issue
Block a user