update Area + Device
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user