Files
assetmgt/equipment_data.php
“VeLiTi” 24481279d5 Refactor user session handling and permissions management
- Updated session variables to use 'authorization' array instead of 'username' for user identification across multiple files.
- Introduced a new function `getUserPermissions` to consolidate user permissions retrieval based on assigned roles.
- Modified API calls to use the new authorization structure and updated endpoints to v2.
- Enhanced language support by adding 'PL' to the list of supported languages.
- Cleaned up redundant code and improved session management during user login and registration processes.
- Added a new API endpoint for fetching user permissions based on user ID.
2026-01-19 15:29:16 +01:00

115 lines
4.2 KiB
PHP

<?php
defined(page_security_key) or exit;
$page = 'equipment_data';
//Check if allowed
if (isAllowed($page,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'R') === 0){
header('location: index.php');
exit;
}
//PAGE Security
$update_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'U');
$delete_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'D');
$create_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'C');
// Default input product values
$equipment_data = [
'rowID' => '',
'equipmentid' => '',
'historyid' => '',
'created' => '',
'createdby' => $_SESSION['authorization']['clientID'],
'measurement' => ''
];
$equipmentID = $_GET['equipmentID']??'';
if (isset($_GET['rowID'])) {
// ID param exists, edit an existing product
//CALL TO API
$api_url = '/v1/equipment_data/rowID='.$_GET['rowID'];
$responses = ioServer($api_url,'');
//Decode Payload
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;}
$equipment_data = json_decode(json_encode($responses[0]), true);
}
template_header('Equipment_data', 'equipment_data', 'manage');
$view ='
<form action="" method="post">
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">'.$view_asset_data_text.'</h2>
<a href="index.php?page=equipment&equipmentID='.$equipmentID.'" class="btn alt mar-right-2">←</a>
';
$view .= '</div>';
$view .= '<div class="tabs">
<a href="#" class="active">'.$tab1.'</a>
</div>';
$view .= '<div class="content-block tab-content active">
<div class="form responsive-width-100">
<label for="">'.$view_asset_data_rowID.'</label>
<p>'.$equipment_data['rowID'].'</p>
<label for="">'.$view_asset_data_historyid.'</label>
<p>'.$equipment_data['historyid'].'</p>
<label for="">'.$view_asset_data_ranking.'</label>
<p>'.$equipment_data['healthindex'].'</p>
';
if (isset($_GET['rowID']) && $_GET['rowID'] !='' && !empty($equipment_data['measurement'])){
$measurements = json_decode($equipment_data['measurement'],true);
$view .= '
<label for="">'.$view_asset_data.'</label>
<div class="table">
<table>
<thead>
<tr>
<td>Test</td>
<td>Measurement</td>
<td>Deviaton</td>
</tr>
</thead>
<tbody>
';
foreach ($measurements as $name => $measurement){
$view .='
<tr>
<td>'.$measurement['measurement'].'</td>
<td>'.$measurement['value'].'</td>
<td>'.$measurement['deviation'].'</td>
</tr>
';
}
$view .= '</tbody>
</table>
</div>';
}
$view .= '
</div>
</div';
$view .= '<div class="tabs">
<a href="#">'.$tab3.'</a>
</div>';
$view .= '<div class="content-block tab-content">
<div class="form responsive-width-100">
<label for="productcode">'.$general_created.'</label>
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$equipment_data['created'].'" readonly>
<label for="productcode">'.$general_createdby.'</label>
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$equipment_data['createdby'].'" readonly>
</div>
</div>';
$view .= '</form>';
//Output
echo $view;
template_footer()
?>