From 884d2a3366f03571efc73bd3af995ab81f8d43c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Mon, 12 Jan 2026 15:59:46 +0100 Subject: [PATCH] Enhance product links and translations; update styles and add registration modal - Updated product links in rma.php and rma_manage.php to include icons for better UX. - Improved German, Spanish, Dutch, Polish, Portuguese, and US translations with new phrases for software licenses and user information prompts. - Refactored CSS to remove redundant styles and added new styles for a registration modal, enhancing the overall UI. - Introduced JavaScript variables for user information prompts in softwaretool.php for better localization support. --- api/v2/get/history.php | 63 +- api/v2/post/history.php | 11 +- assets/functions.php | 8 +- assets/softwaretool.js | 210 +++++- contract.php | 2 +- equipment.php | 258 ++++++- login.php | 2 +- product.php | 6 +- products_software_version_manage.php | 17 +- register.php | 799 +++++++++++++++------- rma.php | 4 +- rma_manage.php | 4 +- settings/translations/translations_DE.php | 17 +- settings/translations/translations_ES.php | 16 +- settings/translations/translations_NL.php | 16 +- settings/translations/translations_PL.php | 8 +- settings/translations/translations_PT.php | 16 +- settings/translations/translations_US.php | 16 +- softwaretool.php | 20 +- style/admin.css | 181 ++++- style/admin_login.css | 13 +- 21 files changed, 1332 insertions(+), 355 deletions(-) diff --git a/api/v2/get/history.php b/api/v2/get/history.php index 8967b7c..e433d1d 100644 --- a/api/v2/get/history.php +++ b/api/v2/get/history.php @@ -64,11 +64,64 @@ if(isset($get_content) && $get_content!=''){ //build up search $clause .= ' AND (h.rowID like :'.$v[0].' OR h.createdby like :'.$v[0].')'; } - elseif ($v[0] == 'type' && $v[1] == 'servicereport') { - //Filter out only relevant servicereports - $filter_key_1 = '"%serialnumber%"'; - $filter_key_2 = '"ServiceReport"'; - $clause .= ' AND h.type = '.$filter_key_2.' AND NOT e.productrowid = "31" AND h.description like '.$filter_key_1; + elseif ($v[0] == 'serialnumber') { + //build up serialnumber + //check if multiple serialnumbers are provided + if (str_contains($v[1], ',')){ + $inputs = explode(",",$v[1]); + $new_querystring = ''; //empty querystring + $x=0; + foreach($inputs as $input){ + //create key + $new_key = $v[0].'_'.$x; + //inject new key/value to array + $criterias[$new_key] = $input; + $new_querystring .= ':'.$new_key.','; + $x++; + } + //remove obsolete last character from new_querystring + $new_querystring = substr($new_querystring,0, -1); + //add new_querystring to clause + $clause .= ' AND e.serialnumber IN ('.$new_querystring.')'; + //remove original key/value from array + unset($criterias[$v[0]]); + } + else { + $clause .= ' AND e.serialnumber IN (:'.$v[0].')'; + } + } + elseif ($v[0] == 'type') { + if ($v[1] == 'servicereport') { + //Filter out only relevant servicereports + $filter_key_1 = '"%serialnumber%"'; + $filter_key_2 = '"ServiceReport"'; + $clause .= ' AND h.type = '.$filter_key_2.' AND NOT e.productrowid = "31" AND h.description like '.$filter_key_1; + //remove from criterias to prevent double binding + unset($criterias[$v[0]]); + } + elseif (str_contains($v[1], ',')) { + //check if multiple types are provided + $inputs = explode(",",$v[1]); + $new_querystring = ''; //empty querystring + $x=0; + foreach($inputs as $input){ + //create key + $new_key = $v[0].'_'.$x; + //inject new key/value to array + $criterias[$new_key] = $input; + $new_querystring .= ':'.$new_key.','; + $x++; + } + //remove obsolete last character from new_querystring + $new_querystring = substr($new_querystring,0, -1); + //add new_querystring to clause + $clause .= ' AND h.type IN ('.$new_querystring.')'; + //remove original key/value from array + unset($criterias[$v[0]]); + } + else { + $clause .= ' AND h.type = :'.$v[0]; + } } elseif ($v[0] == 'created') { //build up search diff --git a/api/v2/post/history.php b/api/v2/post/history.php index 2cbe397..b24d723 100644 --- a/api/v2/post/history.php +++ b/api/v2/post/history.php @@ -24,7 +24,11 @@ function checkSerial($serialinput){ } //CHECK IF SN AND PAYLOAD IS SEND => FROM EXTERNAL APPS -if (isset($post_content['sn']) && isset($post_content['payload'])){ +if (isset($post_content['sn']) && (isset($post_content['payload']) || isset($post_content['testdetails']))){ + + if (!isset($post_content['payload'])) { + $post_content['payload'] = $post_content['testdetails']; + } if (!empty($post_content['sn']) && !empty($post_content['payload'])) { // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -148,6 +152,11 @@ if (isset($post_content['sn']) && isset($post_content['payload'])){ $servicetoolHistoryUpdate = 1; $sn_service = $post_content['sn_service']; break; + + case 'customer': //update from Portal + $historytype = 'Customer'; + $equipmentUpdate = 1; + break; default: $historytype = 'Other'; diff --git a/assets/functions.php b/assets/functions.php index 647f357..77ec17a 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -1755,7 +1755,7 @@ function warrantyStatus($input){ if (!empty($input) && $input < $warrantydate){ $warranty_date_due = ''.$warranty_outdated_text.''; } else { - $warranty_date_due =''.$warranty_recent.' ('.date('Y-m-d', strtotime($input. ' + 365 days')).')'; + $warranty_date_due =''.$warranty_recent.' ('.date('Y-m-d', strtotime($input. ' + 365 days')).')'; } return $warranty_date_due; @@ -1788,7 +1788,7 @@ function serviceStatus($input){ if (!empty($input) && $input < $servicedate){ $service_date_due = ''.$service_renewal_text.''; } else { - $service_date_due =''.$service_recent.' ('.date('Y-m-d', strtotime($input. ' + 365 days')).')'; + $service_date_due =''.$service_recent.' ('.date('Y-m-d', strtotime($input. ' + 365 days')).')'; } return $service_date_due; @@ -1815,7 +1815,7 @@ function availableFirmware($sw_version,$sw_version_latest){ switch ($sw_version_latest) { case 1: - $message = ''.$firmware_recent_text.''; + $message = ''.$firmware_recent_text.''; break; case 0: @@ -1823,7 +1823,7 @@ function availableFirmware($sw_version,$sw_version_latest){ break; default: - $message =''; + $message =''; break; } diff --git a/assets/softwaretool.js b/assets/softwaretool.js index 74c1be7..be93872 100644 --- a/assets/softwaretool.js +++ b/assets/softwaretool.js @@ -73,7 +73,7 @@ async function connectDeviceForSoftware() { readBar.innerHTML = ''; serialResultsDiv.innerHTML = ''; document.getElementById("softwareCheckStatus").style.display = "none"; - document.getElementById("softwareOptions").style.display = "none"; + document.getElementById("softwareOptionsContainer").style.display = "none"; document.getElementById("noUpdatesMessage").style.display = "none"; document.getElementById("uploadSection").style.display = "none"; @@ -443,12 +443,15 @@ async function fetchSoftwareOptions() { return; } - // Display options in table + // Display options in table (blurred initially) displaySoftwareOptions(options); document.getElementById("softwareCheckStatus").style.display = "none"; - document.getElementById("softwareOptions").style.display = "block"; + document.getElementById("softwareOptionsContainer").style.display = "block"; progressBar("100", "Software options loaded", "#04AA6D"); + // Show user info modal immediately + showUserInfoModal(); + } catch (error) { await logCommunication(`Software options error: ${error.message}`, 'error'); progressBar("0", "Error loading options: " + error.message, "#ff6666"); @@ -642,18 +645,189 @@ function displaySoftwareOptions(options) { }); } +function showUserInfoModal() { + // Create modal overlay + const modal = document.createElement("div"); + modal.id = "userInfoModal"; + modal.style.cssText = ` + display: flex; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0,0,0,0.7); + z-index: 2000; + align-items: center; + justify-content: center; + `; + + // Create modal content + const modalContent = document.createElement("div"); + modalContent.style.cssText = ` + background: white; + border-radius: 12px; + max-width: 500px; + width: 90%; + max-height: 90vh; + overflow-y: auto; + margin: 20px; + box-shadow: 0 20px 60px rgba(0,0,0,0.4); + `; + + modalContent.innerHTML = ` +
+

${typeof TRANS_USER_INFO_REQUIRED !== 'undefined' ? TRANS_USER_INFO_REQUIRED : 'User Information Required'}

+

${typeof TRANS_USER_INFO_DESCRIPTION !== 'undefined' ? TRANS_USER_INFO_DESCRIPTION : 'Please provide your information to continue with software updates'}

+
+
+
+
+ + +
+ +
+ + +
+ +
+ + + +
+ + +
+
+ +
+ + +
+
+
+ `; + + modal.appendChild(modalContent); + document.body.appendChild(modal); + + // Prefill form with customer data from sessionStorage if available + const savedCustomerData = sessionStorage.getItem('customerData'); + if (savedCustomerData) { + try { + const customerData = JSON.parse(savedCustomerData); + if (customerData.name) document.getElementById("userInfoName").value = customerData.name; + if (customerData.email) document.getElementById("userInfoEmail").value = customerData.email; + if (customerData.address) document.getElementById("userInfoAddress").value = customerData.address; + if (customerData.city) document.getElementById("userInfoCity").value = customerData.city; + if (customerData.postal) document.getElementById("userInfoPostal").value = customerData.postal; + if (customerData.country) document.getElementById("userInfoCountry").value = customerData.country; + } catch (e) { + console.warn('Error parsing saved customer data:', e); + } + } + + // Handle form submission + document.getElementById("userInfoForm").onsubmit = async (e) => { + e.preventDefault(); + const formData = new FormData(e.target); + const customerData = { + name: formData.get("name"), + email: formData.get("email"), + address: formData.get("address"), + city: formData.get("city"), + postal: formData.get("postal"), + country: formData.get("country") + }; + + // Save customer data to sessionStorage + sessionStorage.setItem('customerData', JSON.stringify(customerData)); + + // Send to API + await sendUserInfoToAPI(customerData); + + // Close modal + document.body.removeChild(modal); + + // Reveal software options by removing blur + const softwareOptions = document.getElementById("softwareOptions"); + if (softwareOptions) { + softwareOptions.style.filter = "none"; + softwareOptions.style.opacity = "1"; + softwareOptions.style.pointerEvents = "auto"; + } + }; +} + +async function sendUserInfoToAPI(customerData) { + try { + const serviceToken = document.getElementById("servicetoken")?.innerHTML || ''; + const url = link + '/v2/history'; + const bearer = 'Bearer ' + serviceToken; + + const historyData = { + sn: deviceSerialNumber, + type: 'customer', + sn_service: 'Portal', + payload: customerData + }; + + await logCommunication(`Sending user info to API: ${JSON.stringify(historyData)}`, 'sent'); + + const response = await fetch(url, { + method: 'POST', + withCredentials: true, + credentials: 'include', + headers: { + 'Authorization': bearer, + 'Content-Type': 'application/json' + }, + body: JSON.stringify(historyData) + }); + + if (!response.ok) { + console.warn('Failed to send user info:', response.status); + await logCommunication(`Failed to send user info: ${response.status}`, 'error'); + } else { + const result = await response.json(); + console.log("User info sent successfully:", result); + await logCommunication(`User info sent successfully: ${JSON.stringify(result)}`, 'received'); + } + } catch (error) { + console.warn('Error sending user info:', error); + await logCommunication(`Error sending user info: ${error.message}`, 'error'); + } +} + async function selectUpgrade(option) { const price = parseFloat(option.price || 0); const isFree = price === 0; - // If paid upgrade, show payment modal first + // If paid upgrade, show payment modal with pre-filled data if (!isFree) { showPaymentModal(option); return; } - // Free upgrade - show confirmation modal first - showFreeInstallModal(option); + // Free upgrade - proceed directly with saved customer data + const savedCustomerData = sessionStorage.getItem('customerData'); + if (savedCustomerData) { + try { + const customerData = JSON.parse(savedCustomerData); + await downloadAndInstallSoftware(option, customerData); + } catch (e) { + console.warn('Error parsing saved customer data:', e); + showFreeInstallModal(option); + } + } else { + showFreeInstallModal(option); + } } function showFreeInstallModal(option) { @@ -699,22 +873,22 @@ function showFreeInstallModal(option) {
- +
- +
- + - +
- - + +
@@ -837,22 +1011,22 @@ function showPaymentModal(option) {
- +
- +
- + - +
- - + +
diff --git a/contract.php b/contract.php index 0edcb8a..bbe5260 100644 --- a/contract.php +++ b/contract.php @@ -309,7 +309,7 @@ $view .= '
'; //Check for assigned tools foreach ($servicetools as $tools){ - $view .= ''.(($view_equipment == 1)? ''.$tools.'':$tools).''; + $view .= ''.(($view_equipment == 1)? ''.$tools.' ':$tools).''; } $view .= ' diff --git a/equipment.php b/equipment.php index 400e6ae..b0e2cf1 100644 --- a/equipment.php +++ b/equipment.php @@ -60,6 +60,28 @@ $equipment_data = ioServer($api_url,''); //Decode Payload if (!empty($equipment_data )){$equipment_data = decode_payload($equipment_data );}else{$equipment_data = null;} +//CALL TO API FOR CUSTOMER AND WARRANTY DATA (type = customer,Warranty in history) +$api_url = '/v2/history/equipmentID='.$responses->equipmentID.'&type=customer,Warranty'; +$registration_data = ioServer($api_url,''); + +//Decode Payload +if (!empty($registration_data)){$registration_data = json_decode($registration_data);}else{$registration_data = null;} + +// Separate customer and warranty data +$latest_customer = null; +$latest_warranty = null; + +if (is_array($registration_data) && count($registration_data) > 0) { + foreach ($registration_data as $record) { + if ($record->type === 'Customer' && $latest_customer === null) { + $latest_customer = $record; + } + if ($record->type === 'Warranty' && $latest_warranty === null) { + $latest_warranty = $record; + } + } +} + //GET PRODUCTS_SOFTWARE $api_url = '/v1/products_software/productrowid='.$responses->productrowid.'&status=1'; $products_software = ioServer($api_url,''); @@ -163,7 +185,7 @@ $view .= '

'.$view_asset_data_ranking.'

-

'.$total_score.'

+

'.$total_score.'

'.$equipment_label2.'

@@ -175,11 +197,11 @@ $view .= '

'.$product_code.'

-

'.(($view_product == 1)? ''.$responses->productcode.'':$responses->productcode).'

+

'.(($view_product == 1)? ''.$responses->productcode.' ':$responses->productcode).'

'.$product_name.'

-

'.(($view_product == 1)? ''.(${$responses->productname} ?? $responses->productname).'':(${$responses->productname} ?? $responses->productname)).'

+

'.(($view_product == 1)? ''.(${$responses->productname} ?? $responses->productname).' ':(${$responses->productname} ?? $responses->productname)).'

'; if (!empty($media_responses['full_path'])){ $view .=' @@ -217,6 +239,9 @@ $view .='

'.$general_section.'

'.$section.'

+
+

'.(($latest_customer || $latest_warranty) ? ''.($register_title ?? 'Registration').' ' : '').'

+
'; $view .= '
'; @@ -368,8 +393,8 @@ $view .= '
$view .= ' '.$data->rowID.' - '.(($view_history == 1)? ''.$data->historyid.'':$data->historyid).' - '.$data->healthindex.' + '.(($view_history == 1)? ''.$data->historyid.' ':$data->historyid).' + '.$data->healthindex.' '; } $view .= ' @@ -448,7 +473,228 @@ if ($update_allowed === 1){ $view .='
'; //OUTPUT -echo $view; +echo $view; + +// Add customer data modal if data exists +if ($latest_customer || $latest_warranty) { + $customer_payload = $latest_customer ? json_decode($latest_customer->description, true) : null; + $warranty_payload = $latest_warranty ? json_decode($latest_warranty->description, true) : null; + + echo ' +
+
+
+

'.($register_title ?? 'Registration').'

+ +
+ + + + + +
+
'; + + if ($warranty_payload) { + // Check if warranty is still active + $warranty_end_date = $warranty_payload['end_date'] ?? null; + $warranty_display = '-'; + $warranty_payload['createdby'] = $latest_warranty->createdby ?? '-'; + + if ($warranty_end_date) { + $end_date_obj = new DateTime(substr($warranty_end_date, 0, 10)); // Extract date part (YYYY-MM-DD) + $current_date_obj = new DateTime(date('Y-m-d')); + + if ($end_date_obj >= $current_date_obj) { + // Warranty is still active + $warranty_display = ($warranty_recent ?? 'Active') . ' - ' . htmlspecialchars($warranty_end_date); + } else { + // Warranty has expired + $warranty_display = ($warranty_outdated_text ?? 'Expired'); + } + } + + echo ' +
+ +

'.$warranty_display.'

+
+
+ +

'.htmlspecialchars($warranty_payload['organization'] ?? '-').'

+
+
+ +

+ '.htmlspecialchars($warranty_payload['createdby'] ?? '-').' +

+
+
+ +

'.htmlspecialchars($warranty_payload['phone'] ?? '-').'

+
+
+
+ +

'.htmlspecialchars($warranty_payload['city'] ?? '-').'

+
+
+ +

'.htmlspecialchars($warranty_payload['country'] ?? '-').'

+
+
+
+ +

'.getRelativeTime($latest_warranty->created).'

+
'; + } else { + echo ' +
+ +

No warranty information available

+
'; + } + + echo ' +
+
+ + + +
+
+ + + '; +} template_footer() diff --git a/login.php b/login.php index 0e87162..3e47de4 100644 --- a/login.php +++ b/login.php @@ -140,7 +140,7 @@ echo'