diff --git a/app/Models/DevicesModel.php b/app/Models/DevicesModel.php index aa39d6cbd..d913b6917 100644 --- a/app/Models/DevicesModel.php +++ b/app/Models/DevicesModel.php @@ -917,7 +917,9 @@ public function update($id = null, $data = null): bool } $update = $this->updateFieldData('devices', $update_device); $this->builder->where('id', intval($id)); - $this->builder->update($update); + if (count((array)$update_device) > 0) { + $this->builder->update($update_device); + } if ($this->sqlError($this->db->error())) { return false; } @@ -988,11 +990,11 @@ public function update($id = null, $data = null): bool $updated = false; if (!empty($deviceFields)) { foreach ($deviceFields as $deviceField) { - if (intval($field->id) === intval($deviceField->fields_id)) { + if (intval($field->id) === intval($deviceField->field_id)) { $previous_value = (!empty($deviceField->value)) ? $deviceField->value : ''; - $update = true; + $updated = true; $sql = "UPDATE field SET value = ?, `timestamp` = NOW() WHERE id = ?"; - $this->db->query($sql, [$deviceField->id, $value]); + $this->db->query($sql, [$value, $deviceField->id]); $sql = "INSERT INTO edit_log VALUES (null, ?, ?, 'Field data was updated', ?, ?, 'field', ?, NOW(), ?, ?)"; $this->db->query($sql, [$user_id, $id, $source, 1000, $field->name, $value, $previous_value]); } diff --git a/app/Views/devicesRead.php b/app/Views/devicesRead.php index 3e7bc7270..9ae0d4a8a 100644 --- a/app/Views/devicesRead.php +++ b/app/Views/devicesRead.php @@ -611,7 +611,7 @@ } echo "