Add API endpoints and management pages for software versions and upgrade paths
- Implemented API endpoint for managing software versions in `products_software_versions.php`. - Created management page for software version assignments in `products_software_assignments.php`. - Developed upgrade paths management functionality in `products_software_upgrade_paths_manage.php`. - Enhanced software version details page in `products_software_version.php`. - Added form handling and validation for software version creation and updates in `products_software_version_manage.php`. - Introduced pagination and filtering for software versions in `products_software_versions.php`. - Implemented success message handling for CRUD operations across various pages.
This commit is contained in:
166
product.php
166
product.php
@@ -32,6 +32,7 @@ $update_allowed_edit = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['p
|
||||
$delete_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'D');
|
||||
$create_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'C');
|
||||
$media_update = isAllowed('products_media' ,$_SESSION['profile'],$_SESSION['permission'],'U');
|
||||
$software_update = isAllowed('products_software_assignment' ,$_SESSION['profile'],$_SESSION['permission'],'U');
|
||||
|
||||
//GET Details from URL
|
||||
$GET_VALUES = urlGETdetails($_GET) ?? '';
|
||||
@@ -73,6 +74,12 @@ $products_media = ioServer($api_url,'');
|
||||
//Decode Payload
|
||||
if (!empty($products_media)){$products_media = json_decode($products_media ,true);}else{$products_media = null;}
|
||||
|
||||
//GET ASSIGNED SOFTWARE VERSIONS
|
||||
$api_url = '/v2/products_software_assignment/product_id='.$_GET['rowID'];
|
||||
$products_software_assignment = ioServer($api_url,'');
|
||||
//Decode Payload
|
||||
if (!empty($products_software_assignment)){$products_software_assignment = json_decode($products_software_assignment,true);}else{$products_software_assignment = null;}
|
||||
|
||||
if ($media_update == 1){
|
||||
//GET ALL MEDIA
|
||||
$api_url = '/v2/media/list=product_image';
|
||||
@@ -320,50 +327,28 @@ $view .= '
|
||||
}
|
||||
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.($product_version_software ?? '').'
|
||||
<a href="index.php?page=products_software&productrowid='.$_GET['rowID'].'" class="btn2"> + </a>
|
||||
</div>';
|
||||
if (!empty($product_software)){
|
||||
$view .= '
|
||||
<div class="table">
|
||||
<table class="sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>'.$product_status.'</th>
|
||||
<th>'.$product_version_version.'</th>
|
||||
<th>'.$equipment_label5.'</th>
|
||||
<th>'.$product_version_software .'</th>
|
||||
<th>'.ucfirst($register_mandatory).'</th>
|
||||
<th>'.ucfirst($general_sort_type_3).'</th>
|
||||
<th>'.$general_actions.'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($product_software as $version){
|
||||
|
||||
$view .= '<tr>
|
||||
<td>'.$version->rowID.'</td>
|
||||
<td>'.(($version->status == 1)? '<span class="status enabled">'.$prod_status_1:'<span class="status">'.$prod_status_0).'</td>
|
||||
<td>'.$version->version.'</td>
|
||||
<td>'.$version->hw_version.'</td>
|
||||
<td>'.$version->software.'</td>
|
||||
<td>'.(($version->mandatory == 1)? $general_yes: $general_no).'</td>
|
||||
<td>'.(($version->latest == 1)? $general_yes: $general_no).'</td>
|
||||
<td><a href="index.php?page=products_software&productrowid='.$_GET['rowID'].'&rowID='.$version->rowID.'" class="btn_link">'.$general_view.'</a></td>
|
||||
</tr>';
|
||||
}
|
||||
<h2 class="responsive-width-100">'.($products_software_assignment_header ?? 'Software').' <a href="index.php?page=products_software_assignments&productrowid='.$_GET['rowID'].'" class="btn2">Manage</a></h2>
|
||||
<div id="selectedSoftware">';
|
||||
if(!empty($products_software_assignment)){
|
||||
foreach ($products_software_assignment as $assignment){
|
||||
// Get software version details
|
||||
$api_url = '/v2/products_software_versions/rowID=' . $assignment['software_version_id'];
|
||||
$version_details = ioServer($api_url, '');
|
||||
$version = json_decode($version_details);
|
||||
if (!empty($version)) {
|
||||
$version = $version[0];
|
||||
$view .= '
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
';
|
||||
<div class="software-container" style="display: inline-block; position: relative; margin: 5px; padding: 10px; border: 1px solid #ccc;">
|
||||
<strong>' . $version->name . '</strong><br>
|
||||
Version: ' . $version->version . '<br>
|
||||
HW: ' . $version->hw_version . '
|
||||
</div>';
|
||||
}
|
||||
|
||||
$view .= '
|
||||
}
|
||||
}
|
||||
$view .='</div>
|
||||
</div>
|
||||
';
|
||||
</div>';
|
||||
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
@@ -500,6 +485,105 @@ $view .='</div>
|
||||
</script>
|
||||
';
|
||||
|
||||
$view .= '<dialog id="softwareSelector">
|
||||
<h3>'.(isset($software_select) ? ${$software_select} : 'Select Software Versions').'</h3>
|
||||
<div id="softwareGrid">';
|
||||
if ($software_update == 1){
|
||||
if (isset($software_versions_all) && is_array($software_versions_all)){
|
||||
foreach ($software_versions_all as $software_version){
|
||||
$view .= '
|
||||
<div class="software-item" id="'.$software_version['rowID'].'" onclick="toggleSoftware(this)" style="border: 1px solid #ccc; padding: 10px; margin: 5px; cursor: pointer;">
|
||||
<strong>' . $software_version['name'] . '</strong><br>
|
||||
Version: ' . $software_version['version'] . '<br>
|
||||
HW: ' . $software_version['hw_version'] . '
|
||||
<details style="margin-top: 10px;">
|
||||
<summary>Upgrade Paths</summary>
|
||||
<ul>';
|
||||
// Find upgrade paths
|
||||
if (isset($upgrade_paths_all) && is_array($upgrade_paths_all)){
|
||||
foreach ($upgrade_paths_all as $path) {
|
||||
if ($path['from_version_id'] == $software_version['rowID'] || $path['to_version_id'] == $software_version['rowID']) {
|
||||
$from_ver = '';
|
||||
$to_ver = '';
|
||||
foreach ($software_versions_all as $v) {
|
||||
if ($v['rowID'] == $path['from_version_id']) $from_ver = $v['version'];
|
||||
if ($v['rowID'] == $path['to_version_id']) $to_ver = $v['version'];
|
||||
}
|
||||
$view .= '<li>' . $from_ver . ' -> ' . $to_ver . ' (Price: ' . $path['price'] . ' ' . $path['currency'] . ')</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$view .= '
|
||||
</ul>
|
||||
</details>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
}
|
||||
}
|
||||
$view .= '
|
||||
</div>
|
||||
<br>
|
||||
<button onclick="confirmSoftwareSelection()">Confirm Selection</button>
|
||||
<button onclick="closeSoftwareSelector()">Cancel</button>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
const softwareDialog = document.getElementById(\'softwareSelector\');
|
||||
const softwarePreviewContainer = document.getElementById(\'selectedSoftwarePreview\');
|
||||
const softwarePreviewID = document.getElementById(\'selectedSoftwareID\');
|
||||
|
||||
function openSoftwareDialog(){
|
||||
softwareDialog.showModal();
|
||||
document.querySelectorAll(\'#softwareGrid .software-item\').forEach(item => {item.style.border = \'1px solid #ccc\';});
|
||||
}
|
||||
|
||||
function toggleSoftware(item) {
|
||||
if (item.style.border === \'2px solid blue\') {
|
||||
item.style.border = \'1px solid #ccc\';
|
||||
} else {
|
||||
item.style.border = \'2px solid blue\';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function confirmSoftwareSelection() {
|
||||
// Get all selected software versions
|
||||
const selectedSoftware = Array.from(document.querySelectorAll(\'#softwareGrid .software-item[style*="blue"]\'))
|
||||
.map(item => ({
|
||||
id: item.id,
|
||||
name: item.querySelector(\'strong\').textContent
|
||||
}));
|
||||
|
||||
// Update preview
|
||||
let preview = \'\';
|
||||
softwarePreviewContainer.innerHTML = \'\';
|
||||
|
||||
selectedSoftware.forEach(software => {
|
||||
const previewDiv = document.createElement(\'div\');
|
||||
previewDiv.textContent = software.name;
|
||||
previewDiv.style.maxWidth = \'200px\';
|
||||
previewDiv.style.margin = \'5px\';
|
||||
previewDiv.style.padding = \'5px\';
|
||||
previewDiv.style.border = \'1px solid #ccc\';
|
||||
softwarePreviewContainer.appendChild(previewDiv);
|
||||
|
||||
preview += \'<input name="software_versions[]" form="software" type="hidden" value="\'+software.id+\'">\';
|
||||
|
||||
});
|
||||
|
||||
softwarePreviewID.innerHTML = preview;
|
||||
|
||||
softwareDialog.close();
|
||||
}
|
||||
|
||||
function closeSoftwareSelector() {
|
||||
softwareDialog.close();
|
||||
}
|
||||
|
||||
</script>
|
||||
';
|
||||
|
||||
|
||||
|
||||
$view .= '<div class="content-block">
|
||||
|
||||
Reference in New Issue
Block a user