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.
This commit is contained in:
“VeLiTi”
2026-01-12 15:59:46 +01:00
parent be6f73b19c
commit 884d2a3366
21 changed files with 1332 additions and 355 deletions

View File

@@ -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 .= ' <div class="content-block order-details">
</div>
<div class="order-detail">
<h3>'.$view_asset_data_ranking.'</h3>
<p><span class="status '.(($total_score >= 85) ?'enabled' : (($total_score <= 50)? 'disabled' : 'id2')).'">'.$total_score.'</span></p>
<p><span class="'.(($total_score >= 85) ?'' : (($total_score <= 50)? 'status disabled' : 'id2')).'">'.$total_score.'</span></p>
</div>
<div class="order-detail">
<h3>'.$equipment_label2.'</h3>
@@ -175,11 +197,11 @@ $view .= ' <div class="content-block order-details">
</div>
<div class="order-detail">
<h3>'.$product_code.'</h3>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$responses->productrowid.'" class="btn2">'.$responses->productcode.'</a>':$responses->productcode).'</p>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$responses->productrowid.'" class="link-with-icon">'.$responses->productcode.' <i class="fa-solid fa-up-right-from-square"></i></a>':$responses->productcode).'</p>
</div>
<div class="order-detail">
<h3>'.$product_name.'</h3>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$responses->productrowid.'" class="btn2">'.(${$responses->productname} ?? $responses->productname).'</a>':(${$responses->productname} ?? $responses->productname)).'</p>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$responses->productrowid.'" class="link-with-icon">'.(${$responses->productname} ?? $responses->productname).' <i class="fa-solid fa-up-right-from-square"></i></a>':(${$responses->productname} ?? $responses->productname)).'</p>
</div>';
if (!empty($media_responses['full_path'])){
$view .='
@@ -217,6 +239,9 @@ $view .='<div class="content-block order-details">
<h3>'.$general_section.'</h3>
<p>'.$section.'</p>
</div>
<div class="order-detail">
<h3>'.(($latest_customer || $latest_warranty) ? '<a href="#" onclick="showCustomerModal(); return false;" class="link-with-icon">'.($register_title ?? 'Registration').' <i class="fa-solid fa-up-right-from-square"></i></a>' : '').'</h3>
</div>
</div>';
$view .= '</div>';
@@ -368,8 +393,8 @@ $view .= '<div class="content-block">
$view .= '<tr onclick="window.location.href=\'index.php?page=equipment_data&equipmentID='.$responses->equipmentID.'&rowID='.$data->rowID.'\'" style="cursor: pointer;">
<td>'.$data->rowID.'</td>
<td>'.(($view_history == 1)? '<a href="index.php?page=history&equipmentID='.$responses->equipmentID.'&historyid='.$data->historyid.'" class="btn2">'.$data->historyid.'</a>':$data->historyid).'</td>
<td><span class="status '.(($data->healthindex >= 85) ?'enabled' : (($data->healthindex <= 50)? 'disabled' : 'id2')).'.">'.$data->healthindex.'</span></td>
<td>'.(($view_history == 1)? '<a href="index.php?page=history&equipmentID='.$responses->equipmentID.'&historyid='.$data->historyid.'" class="link-with-icon">'.$data->historyid.' <i class="fa-solid fa-up-right-from-square"></i></a>':$data->historyid).'</td>
<td><span class=" '.(($data->healthindex >= 85) ?'' : (($data->healthindex <= 50)? 'status disabled' : 'id2')).'.">'.$data->healthindex.'</span></td>
</tr>';
}
$view .= '
@@ -448,7 +473,228 @@ if ($update_allowed === 1){
$view .='</div>';
//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 '
<div id="customerModal" class="reg-modal">
<div class="reg-modal-content">
<div class="reg-modal-header">
<h3>'.($register_title ?? 'Registration').'</h3>
<button onclick="closeCustomerModal()" class="reg-modal-close">&times;</button>
</div>
<!-- Tabs -->
<div class="reg-tabs">
<a href="#" class="reg-tab-link active" onclick="switchTab(event, \'warrantyTab\')">'.($warranty_status ?? 'Warranty').'</a>
<a href="#" class="reg-tab-link" onclick="switchTab(event, \'registrationTab\')">'.($register_title ?? 'Product Registration').'</a>
</div>
<!-- Warranty Tab Content -->
<div id="warrantyTab" class="reg-tab-content" style="display: block;">
<div class="reg-fields">';
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 '
<div class="reg-field">
<label>'.($warranty_status ?? 'Status').'</label>
<p>'.$warranty_display.'</p>
</div>
<div class="reg-field">
<label>'.($account_name ?? 'Organization').'</label>
<p>'.htmlspecialchars($warranty_payload['organization'] ?? '-').'</p>
</div>
<div class="reg-field">
<label>'.($account_email ?? 'Email').'</label>
<p onclick="copyToClipboard(\''.htmlspecialchars($warranty_payload['createdby'] ?? '').'\')"; class="reg-field-email" title="Click to copy">
<i class="fa-solid fa-envelope"></i> '.htmlspecialchars($warranty_payload['createdby'] ?? '-').'
</p>
</div>
<div class="reg-field">
<label>Phone</label>
<p>'.htmlspecialchars($warranty_payload['phone'] ?? '-').'</p>
</div>
<div class="reg-field-group">
<div class="reg-field">
<label>'.($shipping_city ?? 'City').'</label>
<p>'.htmlspecialchars($warranty_payload['city'] ?? '-').'</p>
</div>
<div class="reg-field">
<label>'.($shipping_country ?? 'Country').'</label>
<p>'.htmlspecialchars($warranty_payload['country'] ?? '-').'</p>
</div>
</div>
<div class="reg-field">
<label>'.($general_created ?? 'Registered').'</label>
<p>'.getRelativeTime($latest_warranty->created).'</p>
</div>';
} else {
echo '
<div class="reg-empty-state">
<i class="fa-solid fa-shield-halved"></i>
<p>No warranty information available</p>
</div>';
}
echo '
</div>
</div>
<!-- Product Registration Tab Content -->
<div id="registrationTab" class="reg-tab-content" style="display: none;">
<div class="reg-fields">
<div class="reg-field">
<label>'.($account_name ?? 'Name').'</label>
<p>'.htmlspecialchars($customer_payload['name'] ?? '-').'</p>
</div>
<div class="reg-field">
<label>'.($account_email ?? 'Email').'</label>
<p onclick="copyToClipboard(\''.htmlspecialchars($customer_payload['email'] ?? '').'\')"; class="reg-field-email" title="Click to copy">
<i class="fa-solid fa-envelope"></i> '.htmlspecialchars($customer_payload['email'] ?? '-').'
</p>
</div>
<div class="reg-field">
<label>'.($shipping_address ?? 'Address').'</label>
<p>'.htmlspecialchars($customer_payload['address'] ?? '-').'</p>
</div>
<div class="reg-field-group">
<div class="reg-field">
<label>'.($shipping_city ?? 'City').'</label>
<p>'.htmlspecialchars($customer_payload['city'] ?? '-').'</p>
</div>
<div class="reg-field">
<label>'.($shipping_zip ?? 'Postal Code').'</label>
<p>'.htmlspecialchars($customer_payload['postal'] ?? '-').'</p>
</div>
</div>
<div class="reg-field">
<label>'.($shipping_country ?? 'Country').'</label>
<p>'.htmlspecialchars($customer_payload['country'] ?? '-').'</p>
</div>
<div class="reg-field">
<label>'.($general_created ?? 'Registered').'</label>
<p>'.getRelativeTime($latest_customer->created).'</p>
</div>
</div>
</div>
</div>
</div>
<script>
function switchTab(event, tabId) {
event.preventDefault();
// Hide all tab contents
const tabContents = document.querySelectorAll(".reg-tab-content");
tabContents.forEach(function(content) {
content.style.display = "none";
});
// Remove active class from all tab links
const tabLinks = document.querySelectorAll(".reg-tab-link");
tabLinks.forEach(function(link) {
link.classList.remove("active");
});
// Show selected tab content
document.getElementById(tabId).style.display = "block";
// Add active class to clicked tab
event.currentTarget.classList.add("active");
}
function showCustomerModal() {
const modal = document.getElementById("customerModal");
if (modal) {
modal.style.display = "flex";
}
}
function closeCustomerModal() {
const modal = document.getElementById("customerModal");
if (modal) {
modal.style.display = "none";
}
}
function copyToClipboard(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(function() {
// Show temporary success message
const originalText = event.target.innerHTML;
event.target.innerHTML = \'<i class="fa-solid fa-check"></i> Copied!\';
event.target.style.background = \'#d4edda\';
setTimeout(function() {
event.target.innerHTML = originalText;
event.target.style.background = \'#f8f9fa\';
}, 2000);
}).catch(function(err) {
console.error(\'Failed to copy: \', err);
fallbackCopyToClipboard(text);
});
} else {
fallbackCopyToClipboard(text);
}
}
function fallbackCopyToClipboard(text) {
const textArea = document.createElement("textarea");
textArea.value = text;
textArea.style.position = "fixed";
textArea.style.left = "-999999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand(\'copy\');
const originalText = event.target.innerHTML;
event.target.innerHTML = \'<i class="fa-solid fa-check"></i> Copied!\';
event.target.style.background = \'#d4edda\';
setTimeout(function() {
event.target.innerHTML = originalText;
event.target.style.background = \'#f8f9fa\';
}, 2000);
} catch (err) {
console.error(\'Fallback copy failed: \', err);
alert(\'Failed to copy email\');
}
document.body.removeChild(textArea);
}
// Close modal on background click
document.addEventListener("click", function(e) {
const modal = document.getElementById("customerModal");
if (modal && e.target === modal) {
closeCustomerModal();
}
});
</script>
';
}
template_footer()