update: lấy dữ liệu mã thẻ từ thiết bị, mở cửa từ phần mềm

This commit is contained in:
2020-10-26 14:25:49 +07:00
parent 579ec676cb
commit 2b88dbb695
7 changed files with 138 additions and 7 deletions

View File

@@ -541,4 +541,15 @@ class DeviceController extends Controller {
}
}
public function actionOpenDoor($id, $door) {
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = "json";
$model = $this->findModel($id);
return json_decode(common::requestToCardService("/ControlDevice", [
"DeviceIP" => $model->ip_address,
"DoorID" => $door
]), true);
}
}
}

View File

@@ -12,6 +12,7 @@ use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\helpers\Html;
use yii\helpers\Url;
use app\models\Device;
/**
* StaffController implements the CRUD actions for Staff model.
@@ -79,7 +80,8 @@ class StaffController extends Controller {
"model" => $model,
"url" => Url::to(["create"]),
"departmentArray" => Department::departmentArray(),
"genderArray" => Staff::$genderArray
"genderArray" => Staff::$genderArray,
"deviceArray" => Device::deviceArray()
])
];
}
@@ -125,7 +127,8 @@ class StaffController extends Controller {
"model" => $model,
"url" => Url::to(["update", "id" => $id]),
"departmentArray" => Department::departmentArray(),
"genderArray" => Staff::$genderArray
"genderArray" => Staff::$genderArray,
"deviceArray" => Device::deviceArray()
])
];
}
@@ -302,4 +305,13 @@ class StaffController extends Controller {
}
}
public function actionGetRtlog() {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$device_id = Yii::$app->request->post("device");
$device = Device::findOne($device_id);
return json_decode(common::requestToCardService("/GetRTLog", ["DeviceIP" => $device->ip_address]), true);
}
}
}