Initial commit
This commit is contained in:
109
servicereports.php
Normal file
109
servicereports.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
defined(page_security_key) or exit;
|
||||
|
||||
//ini_set('display_errors', '1');
|
||||
//ini_set('display_startup_errors', '1');
|
||||
//error_reporting(E_ALL);
|
||||
|
||||
include_once './assets/functions.php';
|
||||
include_once './settings/settings.php';
|
||||
|
||||
//Check if allowed
|
||||
if (isAllowed('servicereports',$_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=servicereports'.$status.$search;
|
||||
//GET Details from URL
|
||||
$GET_VALUES = urlGETdetails($_GET) ?? '';
|
||||
//CALL TO API FOR History
|
||||
$api_url = '/v1/equipments/type=ServiceReport&'.$GET_VALUES.'&history=';
|
||||
$history = ioServer($api_url,'');
|
||||
|
||||
//Decode Payload
|
||||
if (!empty($history)){$history = decode_payload($history);}else{$history = null;}
|
||||
|
||||
//Return QueryTotal from API
|
||||
$api_url = '/v1/equipments/type=ServiceReport&'.$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('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>';
|
||||
|
||||
$view .= '
|
||||
<div class="content-header responsive-flex-column pad-top-5">
|
||||
<form action="" method="get">
|
||||
<input type="hidden" name="page" value="servicereports">
|
||||
<div class="search">
|
||||
<label for="search">
|
||||
<input id="search" type="text" name="search" placeholder="'.$servicereports_Search.'" value="" class="responsive-width-100">
|
||||
<i class="fas fa-search"></i>
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
</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);
|
||||
}
|
||||
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.$servicereports_details.'
|
||||
</div>
|
||||
<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();
|
||||
?>
|
||||
Reference in New Issue
Block a user