Files
assetmgt/dashboard.php
“VeLiTi” 670b00eeab Initial commit
2024-03-15 12:43:10 +01:00

148 lines
4.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.php';
//Check if allowed
if (isAllowed('dashboard',$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
//Return QueryTotal from API
$api_url = '/v1/equipments/totals=';
$query_total_equipment = ioServer($api_url,'');
//Decode Payload
if (!empty($query_total_equipment)){$query_total_equipment = decode_payload($query_total_equipment);}else{$query_total_equipment = null;}
//Return Service from API
$api_url = '/v1/equipments/servicedate='.$servicedate.'&totals=';
$query_total_servicable = ioServer($api_url,'');
//Decode Payload
if (!empty($query_total_servicable)){$query_total_servicable = decode_payload($query_total_servicable);}else{$query_total_servicable = null;}
//Return warranty from API
$api_url = '/v1/equipments/warrantydate='.$warrantydate.'&totals=';
$query_total_warranty = ioServer($api_url,'');
//Decode Payload
if (!empty($query_total_warranty)){$query_total_warranty = decode_payload($query_total_warranty);}else{$query_total_warranty = null;}
//Return warranty from API
$api_url = '/v1/equipments/firmware=update&totals=';
$query_total_software = ioServer($api_url,'');
//Decode Payload
if (!empty($query_total_software)){$query_total_software = decode_payload($query_total_software);}else{$query_total_software = null;}
//Return serviceforecast
$api_url = '/v1/application/totals=/serviceforecast';
$serviceforecast = ioServer($api_url,'');
//Decode Payload
if (!empty($serviceforecast)){$serviceforecast = decode_payload($serviceforecast);}else{$serviceforecast = null;}
//Return warrantyforecast
$api_url = '/v1/application/totals=/warrantyforecast';
$warrantyforecast = ioServer($api_url,'');
//Decode Payload
if (!empty($warrantyforecast)){$warrantyforecast = decode_payload($warrantyforecast);}else{$warrantyforecast = null;}
template_header('Dashboard', 'dashboard');
$view = '
<div class="content-title">
<div class="title">
<i class="fa-solid fa-house"></i>
<div class="txt">
<h2>'.$dashboard_h2.'</h2>
<p>'.$dashboard_p.'</p>
</div>
</div>
</div>';
$view .= '
<div class="dashboard">
<div class="content-block stat">
<div class="data" onclick="location.href=\'index.php?page=equipments\'">
<h3>'.$data_assets_h3.'</h3>
<p>'.$query_total_equipment.'</p>
</div>
<i class="fas fa-box-open"></i>
<div class="footer">
<i class="fa-solid fa-rotate fa-xs"></i>'.$data_assets_text.' </div>
</div>
<div class="content-block stat">
<div class="data" onclick="location.href=\'index.php?page=equipments&warrantydate='.$warrantydate.'\'">
<h3>'.$data_warranty_h3.'</h3>
<p>'.$query_total_warranty.'</p>
</div>
<i class="fa-solid fa-calendar-check"></i>
<div class="footer">
<i class="fa-solid fa-rotate fa-xs"></i>'.$data_warranty_text.'
</div>
</div>
<div class="content-block stat">
<div class="data" onclick="location.href=\'index.php?page=equipments&servicedate='.$servicedate.'\'">
<h3>'.$data_service_h3.'</h3>
<p>'.$query_total_servicable.'</p>
</div>
<i class="fas fa-clipboard-check"></i>
<div class="footer">
<i class="fa-solid fa-rotate fa-xs"></i>'.$data_service_text.'
</div>
</div>
<div class="content-block stat">
<div class="data" onclick="location.href=\'index.php?page=equipments&firmware=update\'">
<h3>'.$data_software_h3.'</h3>
<p>'.$query_total_software.'</p>
</div>
<i class="fa-solid fa-calendar-check"></i>
<div class="footer">
<i class="fa-solid fa-rotate fa-xs"></i>'.$data_software_text.'
</div>
</div>
</div>';
$warranty = serviceforecast(json_decode(json_encode($warrantyforecast), true), 'warranty') ?? '';
$forecast = serviceforecast(json_decode(json_encode($serviceforecast), true), 'service') ?? '';
$view .= '
<div class="content-block-wrapper">
<div class="content-block order-details">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.$data_warranty_text_forecast.'
</div>'.$warranty.'</div>
<div class="content-block order-details">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.$data_service_text_forecast.'
</div>'.$forecast.'</div>
</div>
';
$view .= '<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.$dashboard_news.'
</div>
<textarea id="" name="" placeholder="'.$dashboard_news.'" style="width: 100%;height: 150px;">
'.((maintenance_mode) ? maintenance_mode_notification : '').'
'.news.'
</textarea>
</div>
';
//OUTPUT
echo $view;
template_footer();