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:
“VeLiTi”
2025-12-15 14:52:50 +01:00
parent 2b42013e23
commit bdb460c046
26 changed files with 2969 additions and 67 deletions

View File

@@ -0,0 +1,180 @@
<?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';
// Fallback translations
if (!isset($software_versions_h2)) $software_versions_h2 = 'Software Versions';
if (!isset($software_versions_p)) $software_versions_p = 'Manage software versions for products.';
if (!isset($button_create_software_version)) $button_create_software_version = 'Create Software Version';
if (!isset($software_version_search)) $software_version_search = 'Search versions';
if (!isset($message_no_software_versions)) $message_no_software_versions = 'No software versions found.';
if (!isset($message_sv_1)) $message_sv_1 = 'Software version created successfully!';
if (!isset($message_sv_2)) $message_sv_2 = 'Software version updated successfully!';
if (!isset($message_sv_3)) $message_sv_3 = 'Software version deleted successfully!';
//SET ORIGIN FOR NAVIGATION
$prev_page = $_SESSION['prev_origin'] ?? '';
$page = $_SESSION['origin'] = 'products_software_versions';
//Check if allowed
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
//GET PARAMETERS
$pagination_page = isset($_GET['p']) ? $_GET['p'] : 1;
$status = isset($_GET['status']) ? '&status='.$_GET['status'] : '';
$search = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
// Determine the URL
$url = 'index.php?page=products_software_versions'.$status.$search;
//GET Details from URL
$GET_VALUES = urlGETdetails($_GET) ?? '';
//CALL TO API
$api_url = '/v2/products_software_versions/'.$GET_VALUES;
$responses = ioServer($api_url,'');
//Decode Payload
if (!empty($responses)){$responses = json_decode($responses);}else{$responses = null;}
//Return QueryTotal from API
$api_url = '/v2/products_software_versions/'.$GET_VALUES.'&totals=';
$query_total = ioServer($api_url,'');
//Decode Payload
if (!empty($query_total)){$query_total = json_decode($query_total,);}else{$query_total = null;}
// Handle success messages
if (isset($_GET['success_msg'])) {
if ($_GET['success_msg'] == 1) {
$success_msg = $message_sv_1;
}
if ($_GET['success_msg'] == 2) {
$success_msg = $message_sv_2;
}
if ($_GET['success_msg'] == 3) {
$success_msg = $message_sv_3;
}
}
template_header('Software Versions', 'products_software_versions','view');
$view = '
<div class="content-title">
<div class="title">
<i class="fa-solid fa-code-branch"></i>
<div class="txt">
<h2>'.$software_versions_h2.' ('.$query_total.')</h2>
<p>'.$software_versions_p.'</p>
</div>
</div>
</div>';
if (isset($success_msg)){
$view .= ' <div class="msg success">
<i class="fas fa-check-circle"></i>
<p>'.$success_msg.'</p>
<i class="fas fa-times"></i>
</div>';
}
$view .= '
<div class="content-header responsive-flex-column pad-top-5">
<a href="index.php?page=products_software_version_manage" class="btn">'.$button_create_software_version.'</a>
<form action="" method="get">
<input type="hidden" name="page" value="products_software_versions">
<div class="filters">
<a href="#"><i class="fa-solid fa-filter"></i>'.$general_filters.'</a>
<div class="list">
<select name="status">
<option value="" disabled selected>'.$prod_status_text.'</option>
<option value="0"'.($status==0?' selected':'').'>'.$prod_status_0.'</option>
<option value="1"'.($status==1?' selected':'').'>'.$prod_status_1.'</option>
</select>
<button type="submit">'.$button_apply.'</button>
</div>
</div>
<div class="search">
<label for="search">
<input id="search" type="text" name="search" placeholder="'.$software_version_search.'" value="" class="responsive-width-100">
<i class="fas fa-search"></i>
</label>
</div>
</form>
</div>
';
$view .= '
<div class="content-block">
<div class="table">
<table class="sortable">
<thead>
<tr>
<th>Name</th>
<th>Version</th>
<th>HW Version</th>
<th>Mandatory</th>
<th>Latest</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
';
if (empty($responses)){
$view .= '
<tr>
<td colspan="7" style="text-align:center;">'.$message_no_software_versions.'</td>
</tr>';
}
else {
foreach ($responses as $response){
$view .= '
<tr>
<td>'.$response->name.'</td>
<td>'.$response->version.'</td>
<td>'.$response->hw_version.'</td>
<td>'.($response->mandatory ? 'Yes' : 'No').'</td>
<td>'.($response->latest ? 'Yes' : 'No').'</td>
<td>'.($response->status ? 'Active' : 'Inactive').'</td>
<td><a href="index.php?page=products_software_version&rowID='.$response->rowID.'" class="btn_link">View</a></td>
</tr>
';
}
}
$view .= '
</tbody>
</table>
</div>
</div>
';
$view.='<div class="pagination">';
if ($pagination_page > 1) {
$page = $pagination_page-1;
$view .= '<a href="'.$url.'&p=1">'.$general_first.'</a>';
$view .= '<a href="'.$url.'&p='.$page.'">'.$general_prev.'</a>';
}
$totals = ceil($query_total / $page_rows_software_versions) == 0 ? 1 : ceil($query_total / $page_rows_software_versions);
$view .= '<span> '.$general_page.$pagination_page.$general_page_of.$totals.'</span>';
if ($pagination_page * $page_rows_software_versions < $query_total){
$page = $pagination_page+1;
$view .= '<a href="'.$url.'&p='.$page.'">'.$general_next.'</a>';
$view .= '<a href="'.$url.'&p='.$totals.'">'.$general_last.'</a>';
}
$view .= '</div>';
//OUTPUT
echo $view;
template_footer();
?>