From 30df98ae3431add0c595301161493cebeff5092f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Tue, 26 Nov 2024 11:29:02 +0100 Subject: [PATCH] CMXX - Update hardware version when provided --- api/v1/get/products_software.php | 7 +++++++ api/v2/get/products_software.php | 7 +++++++ assets/scripts.js | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/api/v1/get/products_software.php b/api/v1/get/products_software.php index 182188e..20aebaf 100644 --- a/api/v1/get/products_software.php +++ b/api/v1/get/products_software.php @@ -156,6 +156,13 @@ if (!isset($criterias['productrowid']) && isset($criterias['sn']) && $criterias[ $stmt = $pdo->prepare($sql); $stmt->execute([$criterias['version'],$criterias['sn']]); } + + //check if current version is send and update the equipment record + if(isset($criterias['hw_version']) && $criterias['hw_version'] !=''){ + $sql = 'UPDATE equipment SET hw_version = ? WHERE serialnumber = ? '; + $stmt = $pdo->prepare($sql); + $stmt->execute([$criterias['hw_version'],$criterias['sn']]); + } //GET PRODUCTCODE, SW_VERSION_UPGRADE, HW_VERSION from equipment SN $sql = 'SELECT p.productcode, e.sw_version_upgrade, e.hw_version FROM equipment e JOIN products p ON e.productrowid = p.rowID WHERE e.serialnumber = ?'; diff --git a/api/v2/get/products_software.php b/api/v2/get/products_software.php index 3a878b5..e40f9e0 100644 --- a/api/v2/get/products_software.php +++ b/api/v2/get/products_software.php @@ -156,6 +156,13 @@ if (!isset($criterias['productrowid']) && isset($criterias['sn']) && $criterias[ $stmt->execute([$criterias['version'],$criterias['sn']]); } + //check if current version is send and update the equipment record + if(isset($criterias['hw_version']) && $criterias['hw_version'] !=''){ + $sql = 'UPDATE equipment SET hw_version = ? WHERE serialnumber = ? '; + $stmt = $pdo->prepare($sql); + $stmt->execute([$criterias['hw_version'],$criterias['sn']]); + } + //GET PRODUCTCODE, SW_VERSION_UPGRADE, HW_VERSION from equipment SN $sql = 'SELECT p.productcode, e.sw_version_upgrade, e.hw_version FROM equipment e JOIN products p ON e.productrowid = p.rowID WHERE e.serialnumber = ?'; $stmt = $pdo->prepare($sql); diff --git a/assets/scripts.js b/assets/scripts.js index 49656f8..a472121 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -143,7 +143,7 @@ async function getDeviceData(){ function firmwareUpdate(data){ var serialnumber = serial; - var action = '/v2/products_software/sn='+serialnumber+'&version='+fw_name; + var action = '/v2/products_software/sn='+serialnumber+'&version='+fw_name+'&hw_version='+hw; var url = link+action; var bearer = 'Bearer ' + data;