diff --git a/controllers/DeviceController.php b/controllers/DeviceController.php index ecaa391e..dae80f9b 100644 --- a/controllers/DeviceController.php +++ b/controllers/DeviceController.php @@ -579,11 +579,21 @@ class DeviceController extends Controller { } } - public function actionEditDoorName($id) { + public function actionEditDoor($id) { if (Yii::$app->request->post()) { + $post = Yii::$app->request->post(); $model = Door::findOne($id); if ($model) { - $model->name = Yii::$app->request->post("name"); + $model->name = $post["name"]; + if ($model->duration !== $post["duration"]) { + $device = $this->findModel($model->device_id); + common::requestToCardService("/SetDeviceData/DoorDriverTime", [ + "DeviceIP" => $device->ip_address, + "DoorID" => $model->code, + "DoorDriverTime" => $post["duration"] + ]); + $model->duration = $post["duration"]; + } $model->modified_at = time(); $model->save(); } diff --git a/helpers/DeviceGrid.php b/helpers/DeviceGrid.php index d15a8371..21596305 100644 --- a/helpers/DeviceGrid.php +++ b/helpers/DeviceGrid.php @@ -42,7 +42,7 @@ class DeviceGrid extends CommonGrid { 'data' => [ 'href' => Url::to(['doors', 'id' => $model->id]) ], - 'onclick' => "common.form(this, '');" + 'onclick' => "common.form(this, '', true);" ]); // foreach ($doors as $key => $value) { // $html .= Html::button($value->code, [ diff --git a/models/Door.php b/models/Door.php index 32a3fedd..55c03734 100644 --- a/models/Door.php +++ b/models/Door.php @@ -11,6 +11,7 @@ use Yii; * @property int $device_id * @property string $name * @property int $code + * @property int $duration * @property int $created_at * @property int $modified_at */ @@ -29,7 +30,7 @@ class Door extends \yii\db\ActiveRecord { public function rules() { return [ [['device_id', 'name', 'code'], 'required'], - [['device_id', 'code', 'created_at', 'modified_at'], 'integer'], + [['device_id', 'code', 'created_at', 'modified_at', 'duration'], 'integer'], [['name'], 'string', 'max' => 100], ]; } @@ -43,6 +44,7 @@ class Door extends \yii\db\ActiveRecord { 'device_id' => 'Device ID', 'name' => 'Name', 'code' => 'Code', + 'duration' => 'Duration', 'created_at' => 'Created At', 'modified_at' => 'Modified At', ]; diff --git a/views/device/doors.tpl b/views/device/doors.tpl index c04aa7d6..9501c213 100644 --- a/views/device/doors.tpl +++ b/views/device/doors.tpl @@ -1,9 +1,10 @@ - + - + + @@ -12,13 +13,23 @@ +
Mã cửaMã cửa Tên cửaSửaThời gian mở cửa (giây)Sửa Mở cửa
{$d->code} - {$d->name} - $d->id])}"> + {$d->name} + - + + +