CIM77 - Service reports alleen laatste 5

This commit is contained in:
“VeLiTi”
2024-05-16 15:56:20 +02:00
parent 7612073a5f
commit e4cc9f4ef3
6 changed files with 50 additions and 11 deletions

View File

@@ -119,9 +119,26 @@ elseif (isset($criterias['totals']) && $criterias['totals'] =='' && isset($crite
//Request for total rows for history reports
$sql ='SELECT count(*) as count from history h LEFT JOIN equipment e ON h.equipmentid = e.rowID '.$whereclause.'';
}
elseif (isset($criterias['history']) && $criterias['history'] ==''){
elseif (isset($criterias['history']) && $criterias['history'] != ''){
//History INDICATOR
/*
0 Show All
1 Created DESC, LIMIT 5
*/
switch ($criterias['history']) {
case 1:
$sort = ' ORDER BY h.created DESC LIMIT 0,'.$page_rows_equipment_servicereporst;
break;
default:
$sort = '';
break;
}
//request history
$sql ='SELECT h.rowID as historyID, e.rowID as equipmentID, h.equipmentid as h_equipmentid, e.serialnumber, h.type, h.description, h.created, h.createdby from history h LEFT JOIN equipment e ON h.equipmentid = e.rowID '.$whereclause.'';
$sql ='SELECT h.rowID as historyID, e.rowID as equipmentID, h.equipmentid as h_equipmentid, e.serialnumber, h.type, h.description, h.created, h.createdby from history h LEFT JOIN equipment e ON h.equipmentid = e.rowID '.$whereclause.$sort;
}
else {
// GET SORT INDICATOR
@@ -205,6 +222,14 @@ if (!empty($criterias)){
}
}
}
//------------------------------------------
// Debuglog
//------------------------------------------
if (debug){
$message = $date.';'.$sql.';'.$username;
debuglog($message);
}
//------------------------------------------
//Add paging details
//------------------------------------------
@@ -213,7 +238,7 @@ if(isset($criterias['totals']) && $criterias['totals']==''){
$messages = $stmt->fetch();
$messages = $messages[0];
}
elseif ((isset($criterias['history']) && $criterias['history'] =='') || (isset($criterias['download']) && $criterias['download'] =='')){
elseif ((isset($criterias['history']) && $criterias['history'] !='') || (isset($criterias['download']) && $criterias['download'] =='')){
//Excute Query
$stmt->execute();
//Get results

View File

@@ -900,16 +900,22 @@ function serviceEvents ($messages){
<td><a href="index.php?page=render_service_report&historyID='.$message->historyID.'" class="btn_link">PDF</a></td>
</tr>';
}
$view_data .= '</tbody>';
}
//CHECK IF OUTPUT IS MORE THAN X (config setting)
if (count($messages) == $page_rows_equipment_servicereporst){
$view_data .= '<tr>
<td><a href="index.php?page=servicereports&search='.$message->h_equipmentid.'" class="btn_link">'.$general_actions_more.'</a></td>
</tr>';
}
if ($view_data == ''){
$view_data = '<tr>
<td colspan="4" style="text-align:center;">'.$service_report_no_text.'</td>
</tr>';
}
$view_data .= '</tbody>';
$view_footer = '</table>';
$view = $view_header.$view_data.$view_footer;

View File

@@ -36,7 +36,7 @@ if (!empty($responses)){$responses = decode_payload($responses);}else{$responses
$responses = $responses[0];
//CALL TO API FOR History
$api_url = '/v1/equipments/equipmentID='.$_GET['equipmentID'].'&type=ServiceReport&history=';
$api_url = '/v1/equipments/equipmentID='.$_GET['equipmentID'].'&type=ServiceReport&history=1';
$history = ioServer($api_url,'');
//Decode Payload

View File

@@ -8,8 +8,15 @@ defined(page_security_key) or exit;
include_once './assets/functions.php';
include_once './settings/settings.php';
//SET PAGE ORIGIN FOR NAVIGATION AND SECURITY
$prev_page = $_SESSION['prev_origin_equipment'] ?? '';
$page = 'servicereports';
//create backbutton to prev_origin
$back_btn_orgin = ($prev_page != '')? '<a href="'.$prev_page.'" class="btn alt mar-right-2">'.$button_back.'</a>':'';
//Check if allowed
if (isAllowed('servicereports',$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
@@ -24,7 +31,7 @@ $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=';
$api_url = '/v1/equipments/type=ServiceReport&'.$GET_VALUES.'&history=0';
$history = ioServer($api_url,'');
//Decode Payload
@@ -46,6 +53,7 @@ $view = '
<p>'.$servicereports_p.'</p>
</div>
</div>
'.$back_btn_orgin.'
</div>';
$view .= '

View File

@@ -55,6 +55,7 @@ $general_first = '↤'; // <-First;
$general_view = 'Bekijk';
$general_actions = 'Acties';
$general_actions_more = 'Meer resultaten';
$general_profile = 'Profiel';
$general_logout = 'Uitloggen';

View File

@@ -55,6 +55,7 @@ $general_first = '↤'; // <-First;
$general_view = 'View';
$general_actions = 'Actions';
$general_actions_more = 'Show more';
$general_profile = 'Profile';
$general_logout = 'Logout';
@@ -240,7 +241,6 @@ $product_serialized = 'Serialized';
$product_build = 'Build';
$product_sales = 'Sales';
$part_type1 = 'Product';
$part_type2 = 'Sparepart';
$part_type3 = 'Loose_item';
@@ -277,7 +277,6 @@ $User_pw_reset = 'Password reset';
$User_pw_login_count = 'Failed login attempts';
$User_block = 'Blocked';
$reset_message = 'Password reset started => See your email inbox for further instructions, you will be redirected to the login page.';
$reset_message2 = 'Resettoken not valid, you will be redirected';
$reset_message3 = 'Password minimal length of 6 characters';