- 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.
163 lines
5.9 KiB
PHP
163 lines
5.9 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
|
|
$_SESSION['prev_origin'] = $_SERVER['REQUEST_URI'];
|
|
$page = $_SESSION['origin'] = 'histories';
|
|
|
|
//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['type']) ? '&type='.$_GET['type'] : '';
|
|
$search = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
|
|
|
|
// Determine the URL
|
|
$url = 'index.php?page=histories'.$status.$search;
|
|
//GET Details from URL
|
|
$GET_VALUES = urlGETdetails($_GET) ?? '';
|
|
//CALL TO API
|
|
$api_url = '/v1/history/'.$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/history/'.$GET_VALUES.'&totals=';
|
|
$query_total = ioServer($api_url,'');
|
|
//Decode Payload
|
|
if (!empty($query_total)){$query_total = decode_payload($query_total);}else{$query_total = null;}
|
|
|
|
template_header('Histories', 'histories','view');
|
|
$view = '
|
|
<div class="content-title">
|
|
<div class="title">
|
|
<i class="fa-solid fa-box-open"></i>
|
|
<div class="txt">
|
|
<h2>'.$history_h2.' ('.$query_total.')</h2>
|
|
<p>'.$history_p.'</p>
|
|
</div>
|
|
</div>
|
|
<div class="title-actions">
|
|
<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="histories">
|
|
<div class="filter-row">
|
|
<div class="filter-group">
|
|
<select name="type">
|
|
<option value="" disabled selected>Type</option>
|
|
<option value="'.$type1.'"'.($status==$type1 ?' selected':'').'>'.$type1.'</option>
|
|
<option value="'.$type2.'"'.($status==$type2 ?' selected':'').'>'.$type2.'</option>
|
|
<option value="'.$type3.'"'.($status==$type3 ?' selected':'').'>'.$type3.'</option>
|
|
<option value="'.$type9.'"'.($status==$type9 ?' selected':'').'>'.$type9.'</option>
|
|
<option value="'.$type14.'"'.($status==$type14 ?' selected':'').'>'.$type14.'</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="filter-group search-group">
|
|
<input type="text" name="search" placeholder="'.$history_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=histories">X</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
';
|
|
|
|
$view .= '
|
|
<div class="content-block">
|
|
<div class="table">
|
|
<table class="sortable">
|
|
<thead>
|
|
<tr>
|
|
<th class="responsive-hidden">'.$history_label1.'</th>
|
|
<th>'.$history_label2.'</th>
|
|
<th class="responsive-hidden">'.$history_label3.'</th>
|
|
<th class="responsive-hidden">'.$history_label4.'</th>
|
|
<th>'.$history_label5.'</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
';
|
|
|
|
if (empty($responses)){
|
|
|
|
$view .= '
|
|
<tr>
|
|
<td colspan="8" style="text-align:center;">'.$history_no_history.'</td>
|
|
</tr>';
|
|
} else {
|
|
|
|
foreach ($responses as $response){
|
|
|
|
$description = json_decode($response->description) ?? $response->description;
|
|
$description = json_encode($description, JSON_PRETTY_PRINT);
|
|
//Replace JSON ITEMS
|
|
$search = ['{', '}', '"',':','[',']',','];
|
|
$replace = ['', '','','=','','',''];
|
|
$description = str_replace($search, $replace, $description);
|
|
|
|
|
|
$view .= '<tr onclick="window.location.href=\'index.php?page=equipment&equipmentID='.$response->equipmentID.'\'" style="cursor: pointer;">
|
|
<td class="responsive-hidden">'.$response->historyID.'</td>
|
|
<td>'.$response->type.'</td>
|
|
<td class="responsive-hidden">'.getRelativeTime($response->created).'</td>
|
|
<td class="responsive-hidden">'.$response->createdby.'</td>
|
|
<td><div style="overflow-y:scroll;height:200px !important;max-width:300px;"><pre>' . $description . '</pre><div></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_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();
|
|
?>
|