Files
assetmgt/products_software_version.php
“VeLiTi” bdb460c046 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.
2025-12-15 14:52:50 +01:00

182 lines
6.3 KiB
PHP

<?php
defined(page_security_key) or exit;
if (debug && debug_id == $_SESSION['id']){
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
}
include_once './assets/functions.php';
include_once './settings/settings_redirector.php';
//SET ORIGIN FOR NAVIGATION
$prev_page = $_SESSION['prev_origin'] ?? '';
$page = 'products_software_version';
//create backbutton to prev_origin
$back_btn_orgin = ($prev_page != '')? '<a href="'.$prev_page.'" class="btn alt mar-right-2">Back</a>':'';
// Fallback translations
if (!isset($button_cancel)) $button_cancel = 'Cancel';
//Check if allowed
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
//GET PARAMETERS && STORE in SESSION for FURTHER USE/NAVIGATION
$pagination_page = $_SESSION['p'] = isset($_GET['p']) ? $_GET['p'] : 1;
//PAGE Security
$page_manage = 'products_software_version_manage';
$update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U');
$update_allowed_edit = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'U');
$delete_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'D');
$create_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'C');
//GET Details from URL
$GET_VALUES = urlGETdetails($_GET) ?? '';
//CALL TO API FOR General information
$api_url = '/v2/products_software_versions/'.$GET_VALUES;
$responses = ioServer($api_url,'');
//Decode Payload
if (!empty($responses)){$responses = json_decode($responses);}else{$responses = null;}
$responses = $responses[0];
//CALL TO API FOR Related Licenses
$api_url = '/v2/products_software_licenses/version_id='.$_GET['rowID'];
$licenses = ioServer($api_url,'');
//Decode Payload
if (!empty($licenses)){$licenses = json_decode($licenses);}else{$licenses = null;}
//CALL TO API FOR Upgrade Paths
$api_url = '/v2/products_software_upgrade_paths/from_version_id='.$_GET['rowID'];
$upgrade_paths_from = ioServer($api_url,'');
//Decode Payload
if (!empty($upgrade_paths_from)){$upgrade_paths_from = json_decode($upgrade_paths_from);}else{$upgrade_paths_from = null;}
$api_url = '/v2/products_software_upgrade_paths/to_version_id='.$_GET['rowID'];
$upgrade_paths_to = ioServer($api_url,'');
//Decode Payload
if (!empty($upgrade_paths_to)){$upgrade_paths_to = json_decode($upgrade_paths_to);}else{$upgrade_paths_to = null;}
// Fetch all software versions for mapping
$api_url = '/v2/products_software_versions/list';
$all_versions_response = ioServer($api_url,'');
$version_map = [];
if (!empty($all_versions_response)) {
$all_versions = json_decode($all_versions_response);
foreach ($all_versions as $ver) {
$version_map[$ver->rowID] = $ver->name . ' (' . $ver->version . ')';
}
}
template_header('Software Version Details', 'products_software_version','view');
$view = '
<div class="content-title">
<div class="title">
<i class="fa-solid fa-code-branch"></i>
<div class="txt">
<h2>Software Version: '.$responses->name.' ('.$responses->version.')</h2>
<p>Details and related information.</p>
</div>
</div>
<div class="action">
<a href="index.php?page='.$_SESSION['origin'].'&p='.$_SESSION['p'].'" class="btn alt mar-right-2">'.$button_cancel.'</a>
'.($update_allowed_edit ? '<a href="index.php?page=products_software_version_manage&id='.$responses->rowID.'" class="btn">Edit</a>' : '').'
</div>
</div>
<div class="content-block order-details">
<div class="block-header">
<i class="fa-solid fa-circle-info"></i>Version Details
</div>
<div class="order-detail">
<h3>Name</h3>
<p>'.$responses->name.'</p>
</div>
<div class="order-detail">
<h3>Version</h3>
<p>'.$responses->version.'</p>
</div>
<div class="order-detail">
<h3>Description</h3>
<p>'.$responses->description.'</p>
</div>
<div class="order-detail">
<h3>HW Version</h3>
<p>'.$responses->hw_version.'</p>
</div>
<div class="order-detail">
<h3>Mandatory</h3>
<p>'.($responses->mandatory ? 'Yes' : 'No').'</p>
</div>
<div class="order-detail">
<h3>Latest</h3>
<p>'.($responses->latest ? 'Yes' : 'No').'</p>
</div>
<div class="order-detail">
<h3>Status</h3>
<p>'.($responses->status ? 'Active' : 'Inactive').'</p>
</div>
<div class="order-detail">
<h3>File Path</h3>
<p>'.$responses->file_path.'</p>
</div>
</div>
<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>Upgrade Paths
<a href="index.php?page=products_software_upgrade_paths_manage&id=' . $_GET['rowID'] . '" class="btn2"> + </a>
</div>
<div class="table">
<table>
<thead>
<tr>
<th>From Version</th>
<th>To Version</th>
<th>Price</th>
<th>Currency</th>
<th>Description</th>
<th>Active</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
';
$all_paths = array_merge($upgrade_paths_from ?: [], $upgrade_paths_to ?: []);
if (empty($all_paths)){
$view .= '<tr><td colspan="7">No upgrade paths found.</td></tr>';
} else {
foreach ($all_paths as $path){
$view .= '
<tr>
<td>' . ($version_map[$path->from_version_id] ?? $path->from_version_id) . '</td>
<td>' . ($version_map[$path->to_version_id] ?? $path->to_version_id) . '</td>
<td>'.$path->price.'</td>
<td>'.$path->currency.'</td>
<td>'.$path->description.'</td>
<td>'.($path->is_active ? 'Yes' : 'No').'</td>
<td><a href="index.php?page=products_software_upgrade_paths_manage&id='.$path->rowID.'" class="btn_link">Edit</a></td>
</tr>
';
}
}
$view .= '
</tbody>
</table>
</div>
</div>
';
//OUTPUT
echo $view;
template_footer();
?>