Files
assetmgt/servicereports.php
“VeLiTi” 18469fe958 Refactor authorization checks to use 'permissions' instead of 'profile' in multiple files
- Updated authorization checks in product management, product attributes, configurations, software, and user management files to use 'permissions' for consistency.
- Ensured that all relevant pages correctly check user permissions for read, update, delete, and create actions.
- Adjusted session variable references to align with the new permissions structure across various modules.
2026-01-20 15:00:00 +01:00

128 lines
4.2 KiB
PHP

<?php
defined(page_security_key) or exit;
if (debug && debug_id == $_SESSION['authorization']['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 PAGE ORIGIN FOR NAVIGATION AND SECURITY
$_SESSION['prev_origin_servicereport'] = $_SERVER['REQUEST_URI'];
$prev_page = ((isset($_SESSION['prev_origin_equipment'])) ? $_SESSION['prev_origin_equipment'] : (isset($_SESSION['prev_origin'])? $_SESSION['prev_origin']:""));
$page = $_SESSION['origin'] = 'servicereports';
//create backbutton to prev_origin
$back_btn_orgin = ($prev_page != '')? '<a href="'.$prev_page.'" class="btn alt mar-right-2">←</a>':'';
//Check if allowed
if (isAllowed($page,$_SESSION['authorization']['permissions'],$_SESSION['authorization']['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'] : '';
$equipmentid = isset($_GET['equipmentid']) ? '&equipmentid='.$_GET['equipmentid'] : '';
// Determine the URL
$url = 'index.php?page=servicereports'.$status.$search.$equipmentid;
//GET Details from URL
$GET_VALUES = urlGETdetails($_GET) ?? '';
//CALL TO API FOR History
$api_url = '/v2/history/type=ServiceReport&'.$GET_VALUES.'';
$history = ioServer($api_url,'');
//Decode Payload
if (!empty($history)){$history = json_decode($history);}else{$history = null;}
//Return QueryTotal from API
$api_url = '/v2/history/type=ServiceReport&'.$GET_VALUES.'&totals=';
$query_total = ioServer($api_url,'');
//Decode Payload
if (!empty($query_total)){$query_total = json_decode($query_total);}else{$query_total = null;}
template_header('Servicereports', 'servicereports','view');
$view = '
<div class="content-title">
<div class="title">
<i class="fa-solid fa-box-open"></i>
<div class="txt">
<h2>'.$servicereports_h2.' ('.$query_total.')</h2>
<p>'.$servicereports_p.'</p>
</div>
</div>
<div class="title-actions">
'.$back_btn_orgin.'
<button id="filter-toggle" class="btn alt" onclick="toggleFilters()">
<i class="fa-solid fa-search"></i>
</button>
</div>
</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="servicereports">
<div class="filter-row">
<div class="filter-group search-group">
<input type="text" name="search" placeholder="'.$servicereports_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=servicereports">X</a>
</div>
</form>
</div>
</div>';
//Get all related service events
if (empty($history)){
$service_events = '
<tr>
<td colspan="8" style="text-align:center;">'.$servicereports_no_history.'</td>
</tr>';
} else {
$service_events = serviceEvents($history,$page);
}
$view .= '<div class="content-block">
<div class="table order-table">'.$service_events.'</div>
</div>
';
$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_history) == 0 ? 1 : ceil($query_total / $page_rows_history);
$view .= '<span> '.$general_page.$pagination_page.$general_page_of.$totals.'</span>';
if ($pagination_page * $page_rows_history < $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();
?>