From dda27fd5774324bfac831330d807a51b5d8e174a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Tue, 18 Mar 2025 11:00:08 +0100 Subject: [PATCH] CMXX - Improved software_update --- api/v0/get/application.php | 2 +- api/v1/get/application.php | 3 +-- api/v1/post/products_software.php | 27 ------------------------- api/v2/get/application.php | 20 +------------------ api/v2/post/products_software.php | 33 ------------------------------- assets/scripts.js | 15 +++----------- equipment_manage.php | 5 +++++ profiles.php | 7 +++++-- 8 files changed, 16 insertions(+), 96 deletions(-) diff --git a/api/v0/get/application.php b/api/v0/get/application.php index f04ed2b..937c012 100644 --- a/api/v0/get/application.php +++ b/api/v0/get/application.php @@ -221,7 +221,7 @@ case 'firmwareUpdate': //Clean input data $hw_device_send = strip_tags(trim($_GET['hw_version'])); $sw_device_send = strip_tags(trim($_GET['sw_version'])); - + //Check exceptions if (in_array($_GET['sn'],$serialnumber_exceptions)){ //Serialnumber found in exceptions include exception file diff --git a/api/v1/get/application.php b/api/v1/get/application.php index c884147..ecb238a 100644 --- a/api/v1/get/application.php +++ b/api/v1/get/application.php @@ -29,8 +29,7 @@ if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} el //------------------------------------------ //default whereclause //------------------------------------------ - -list($whereclause,$condition) = getWhereclause('',$permission,$partner,'get'); +list($whereclause,$condition) = getWhereclause('equipment',$permission,$partner,'get'); //------------------------------------------ //NEW ARRAY diff --git a/api/v1/post/products_software.php b/api/v1/post/products_software.php index ca5f02f..1106cfd 100644 --- a/api/v1/post/products_software.php +++ b/api/v1/post/products_software.php @@ -42,33 +42,6 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '') if ($command == 'insert'){ - if(isset($post_content['software'])){ - //CHECK FOR FILETYPE - $version = $post_content['software']; - $version_file_type = strtolower(substr($version, -4)); // filetype - - //CHECK IF FILETYPE IS ADDED - if ($version_file_type[0] == '.'){ - - //BASED ON FILE TYPE DO THE FOLLOWING - switch ($version_file_type) { - case '.hex': - //USE FULL NAME EXCLUDING - $version = substr($version, 0, -4); - break; - - default: - if (($pos = strpos($version, "_")) !== FALSE) { - $version = substr($version, $pos+1); - $version = substr($version, 0, -4); //remove filetype - } - break; - } - } - //SET CORRECT VERSION - $post_content['version'] = $version; - } - $post_content['latest'] = 1; //New software is always latest $post_content['created'] = $date; $post_content['createdby'] = $username; diff --git a/api/v2/get/application.php b/api/v2/get/application.php index bd4cdfe..dd01c42 100644 --- a/api/v2/get/application.php +++ b/api/v2/get/application.php @@ -29,25 +29,7 @@ if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} el //------------------------------------------ //default whereclause //------------------------------------------ -$whereclause = ''; - -switch ($permission) { - case '4': - $whereclause = ''; - break; - case '3': - $condition = '__salesid___'.$partner->salesid.'___soldto___%'; - $whereclause = 'WHERE e.accounthierarchy like "'.$condition.'"'; - break; - case '2': - $condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search; - $whereclause = 'WHERE e.accounthierarchy like "'.$condition.'"'; - break; - default: - $condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search.'___shipto___'.substr($partner->shipto, 0, strpos($partner->shipto, "-")).'%___location___'.substr($partner->location, 0, strpos($partner->location, "-")).'%'; - $whereclause = 'WHERE e.accounthierarchy like "'.$condition.'"'; - break; -} +list($whereclause,$condition) = getWhereclause('equipment',$permission,$partner,'get'); //------------------------------------------ //NEW ARRAY diff --git a/api/v2/post/products_software.php b/api/v2/post/products_software.php index d99be83..b8bca98 100644 --- a/api/v2/post/products_software.php +++ b/api/v2/post/products_software.php @@ -42,39 +42,6 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '') if ($command == 'insert'){ - if(isset($post_content['software'])){ - //CHECK FOR FILETYPE - $version = $post_content['software']; - $version_file_type = strtolower(substr($version, -4)); // filetype - - //CHECK IF FILETYPE IS ADDED - if ($version_file_type[0] == '.'){ - - //BASED ON FILE TYPE DO THE FOLLOWING - switch ($version_file_type) { - case '.hex': - //USE FULL NAME EXCLUDING - $version = substr($version, 0, -4); - break; - - default: - if (($pos = strpos($version, "_")) !== FALSE) { - $version = substr($version, $pos+1); - $version = substr($version, 0, -4); //remove filetype - } - break; - } - } - //SET CORRECT VERSION - $post_content['version'] = $version; - } - - if (($pos = strpos($post_content['software'], "_")) !== FALSE) { - $version = substr($post_content['software'], $pos+1); - $version = substr($version, 0, -4); //remove filetype - $post_content['version'] = $version; - } - $post_content['latest'] = 1; //New software is always latest $post_content['created'] = $date; $post_content['createdby'] = $username; diff --git a/assets/scripts.js b/assets/scripts.js index df20983..273e918 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -64,7 +64,7 @@ async function listenToPort() { var item = serialResultsDiv.innerHTML; x = Array.from(new Set(item.split(";"))).toString(); - if (x.indexOf("SN=") > 0 && x.indexOf("HW=") > 0 && x.indexOf("FW=") >0 && x.indexOf("HEX_FW=") >0 && x.indexOf("STATE=") > 0) + if (x.indexOf("SN=") > 0 && x.indexOf("HW=") > 0 && x.indexOf("FW=") >0 && x.indexOf("STATE=") > 0) { progressBar("60", "Reading device completed", "#04AA6D"); setTimeout(getDeviceData, 4000); @@ -100,17 +100,8 @@ async function getDeviceData(){ fw = fw.replace(/^0+/, ''); } - if (x.indexOf("HEX_FW=") > 0){ - var startIndex = x.indexOf("HEX_FW="); - var valueStart = startIndex + 7; // - // Find the closing quotation mark - var valueEnd = x.indexOf("\"", valueStart); - // Extract the value - hex_fw = x.substring(valueStart, valueEnd); - } - //Check if HW is retrieved from device - if (x.indexOf("HW=") > 0 && x.indexOf("FW=") >0 && x.indexOf("HEX_FW=") >0){ + if (x.indexOf("HW=") > 0 && x.indexOf("FW=") >0){ var a = x.indexOf("HW="); var b = a + 3; var c = b + 8; @@ -129,7 +120,7 @@ async function getDeviceData(){ } //GET THE COMMITCODE - commitCode = compareCommitCodes(hex_fw,fw); + commitCode = compareCommitCodes("",fw); getServiceID().then(firmwareUpdate); progressBar("80", "checking for available firmware", "#04AA6D"); diff --git a/equipment_manage.php b/equipment_manage.php index ad64876..28a8038 100644 --- a/equipment_manage.php +++ b/equipment_manage.php @@ -41,10 +41,15 @@ $equipment = [ $equipment_ID = $_GET['equipmentID'] ?? ''; + + + if ($equipment_ID !=''){ $url = 'index.php?page=equipment&equipmentID='.$equipment_ID.''; } else { $url = 'index.php?page=equipments'; + //ALLOW UPDATES AT CREATION + $update_allowed_special = 1; } //GET PRODUCTS diff --git a/profiles.php b/profiles.php index d4e13fb..ca1abe7 100644 --- a/profiles.php +++ b/profiles.php @@ -1,8 +1,11 @@