Files
assetmgt/cartests.php
“VeLiTi” 364ee773e4 Enhance UI and functionality across multiple pages
- Added filter panels and search functionality to media, orders, partners, pricelists, products, products attributes, software versions, translations, and users pages.
- Implemented security checks for create, update, and delete permissions on various pages.
- Updated CSS styles for improved layout and responsiveness, including new styles for filter panels and buttons.
- Refactored existing forms to utilize the new filter panel design for a more consistent user experience.
- Adjusted API versioning in servicereport and servicereports pages for better compatibility.
- Improved button icons for filter actions and form submissions for better user interaction.
2025-12-16 11:39:14 +01:00

186 lines
6.0 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';
$page = 'cartests';
//Check if allowed
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
//PAGE Security
$update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U');
$delete_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'D');
$create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'C');
//GET PARAMETERS
$pagination_page = isset($_GET['p']) ? $_GET['p'] : 1;
$car_brand = isset($_GET['car_brand']) ? '&car_brand='.$_GET['car_brand'] : '';
$search = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
// Determine the URL
$url = 'index.php?page='.$page.$car_brand.$search;
//GET Details from URL
$GET_VALUES = urlGETdetails($_GET) ?? '';
//CALL TO API
$api_url = '/v1/cartests/'.$GET_VALUES;
$responses = ioServer($api_url,'');
//Decode Payload
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;}
//Return QueryTotal from API
$api_url = '/v1/cartests/'.$GET_VALUES.'&totals=';
$query_total = ioServer($api_url,'');
//Decode Payload
if (!empty($query_total)){$query_total = decode_payload($query_total);}else{$query_total = null;}
// Handle success messages
if (isset($_GET['success_msg'])) {
if ($_GET['success_msg'] == 1) {
$success_msg = $message_ct_1;
}
if ($_GET['success_msg'] == 2) {
$success_msg = $message_ct_2;
}
if ($_GET['success_msg'] == 3) {
$success_msg = $message_ct_3;
}
}
if (isset($_GET['download'])){
downloadToExcel('cartests',$responses);
}
template_header('Cartests', 'cartests' ,'view');
$view = '
<div class="content-title">
<div class="title">
<i class="fa-solid fa-car"></i>
<div class="txt">
<h2>'.$cartests_h2.' ('.$query_total.')</h2>
<p>'.$cartests_p.'</p>
</div>
</div>
<div class="title-actions">';
if ($create_allowed === 1){
$view .= '<a href="index.php?page=cartest_manage" class="btn">+</a>';
}
$view .= '<button id="filter-toggle" class="btn alt" onclick="toggleFilters()">
<i class="fa-solid fa-search"></i>
</button>
</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 id="filter-panel" class="filter-panel" style="display: none;">
<div class="filter-content">
<form action="" method="get">
<input type="hidden" name="page" value="cartests">
<div class="filter-row">
<div class="filter-group">
<select name="status">
<option value="" disabled selected>Active</option>
<option value="0">'.$disabled.'</option>
<option value="1">'.$enabled.'</option>
</select>
</div>
<div class="filter-group search-group">
<input type="text" name="search" placeholder="'.$cartest_search.'" value="">
</div>
</div>
<div class="filter-actions">
<button type="submit" class="btn"><i class="fas fa-level-down-alt fa-rotate-90"></i></button>
<a class="btn alt" href="index.php?page=cartests">'.$general_filters_clear.'</a>';
//SHOW DOWNLOAD TO EXCELL OPTION ONLY TO ADMIN USERS
if ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4){
$view .= '<a class="btn alt" href="index.php?page=cartests&download=">
<i class="fa-solid fa-download"></i> Download
</a>';
}
$view .= ' </div>
</form>
</div>
</div>
';
$view .= '
<div class="content-block">
<div class="table">
<table class="sortable">
<thead>
<tr>
<th class="responsive-hidden">'.$cartest_rowID.'</th>
<th>'.$cartest_carbrand.'</th>
<th>'.$cartest_cartype.'</th>
<th>'.$general_createdby.'</th>
</tr>
</thead>
<tbody>
';
if (empty($responses)){
$view .= '
<tr>
<td colspan="8" style="text-align:center;">'.$message_no_ct.'</td>
</tr>';
}
else {
foreach ($responses as $response){
$view .= '
<tr onclick="window.location.href=\'index.php?page=cartest&rowID='.$response->rowID.'\'" style="cursor: pointer;">
<td class="responsive-hidden">'.$response->rowID.'</td>
<td>'.$response->carbrand.'</td>
<td>'.$response->cartype.'</td>
<td>'.$response->createdby.'</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_cartest) == 0 ? 1 : ceil($query_total / $page_rows_cartest);
$view .= '<span> '.$general_page.$pagination_page.$general_page_of.$totals.'</span>';
if ($pagination_page * $page_rows_cartest < $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();
?>