update sửa tên cửa

This commit is contained in:
2020-10-30 10:47:16 +07:00
parent cd943030c6
commit 28f23530d0
6 changed files with 116 additions and 17 deletions

View File

@@ -125,11 +125,6 @@ class DeviceController extends Controller {
$model->area_id = $data["Area"];
$model->modified_at = time();
if ($model->save()) {
$doors = Door::find()->andWhere(["device_id" => $id])->all();
foreach ($doors as $key => $value) {
$value->name = $data["Name"] . "-" . $value->code;
$value->save();
}
common::insertSystemLogs(["action" => "update", "description" => "Chỉnh sửa thiết bị: " . $data["Name"], "type" => Yii::$app->controller->id]);
return ["status" => true];
} else
@@ -570,4 +565,30 @@ class DeviceController extends Controller {
}
}
public function actionDoors($id) {
if (Yii::$app->request->isAjax) {
$model = $this->findModel($id);
Yii::$app->response->format = "json";
return [
"title" => "Danh sách cửa: <b>" . $model->name . "</b>",
"form" => $this->renderPartial("doors", [
"model" => $model,
"doors" => Door::find()->andWhere(["device_id" => $id])->all()
])
];
}
}
public function actionEditDoorName($id) {
if (Yii::$app->request->post()) {
$model = Door::findOne($id);
if ($model) {
$model->name = Yii::$app->request->post("name");
$model->modified_at = time();
$model->save();
}
return $id;
}
}
}