From 203686966300a9cbe5cbcc0c65625e88f44e2c68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”>
Date: Fri, 17 May 2024 10:51:45 +0200
Subject: [PATCH] CIM77 - Update
---
api/v1/get/equipments.php | 7 ++++---
api/v1/get/history.php | 6 ++++++
assets/functions.php | 8 ++++----
equipment.php | 2 +-
servicereport.php | 17 ++++++++++-------
servicereports.php | 15 ++++++++-------
6 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/api/v1/get/equipments.php b/api/v1/get/equipments.php
index 377add0..842ba02 100644
--- a/api/v1/get/equipments.php
+++ b/api/v1/get/equipments.php
@@ -133,12 +133,13 @@ elseif (isset($criterias['history']) && $criterias['history'] != ''){
break;
default:
- $sort = '';
+ $current_page = isset($criterias['p']) && is_numeric($criterias['p']) ? (int)$criterias['p'] : 1;
+ $start_page = ($current_page - 1) * $page_rows_history;
+ $sort = ' ORDER BY h.created DESC LIMIT '.$start_page.','.$page_rows_history;
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.$sort;
-
+ $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
diff --git a/api/v1/get/history.php b/api/v1/get/history.php
index 22fbb8f..726e4a2 100644
--- a/api/v1/get/history.php
+++ b/api/v1/get/history.php
@@ -63,6 +63,12 @@ if(isset($get_content) && $get_content!=''){
//build up search
$clause .= ' AND (h.rowID like :'.$v[0].' OR h.createdby like :'.$v[0].')';
}
+ elseif ($v[0] == 'type' && $v[1] == 'servicereport') {
+ //Filter out only relevant servicereports
+ $filter_key_1 = '"%serialnumber%"';
+ $filter_key_2 = '"ServiceReport"';
+ $clause .= ' AND h.type = '.$filter_key_2.' AND h.description like '.$filter_key_1;
+ }
else {//create clause
$clause .= ' AND '.$v[0].' = :'.$v[0];
}
diff --git a/assets/functions.php b/assets/functions.php
index 366ac20..b5339ae 100644
--- a/assets/functions.php
+++ b/assets/functions.php
@@ -826,7 +826,7 @@ function availableFirmware($sw_version, $hw_version){
//------------------------------------------
// show serviceEvents available
//------------------------------------------
-function serviceEvents ($messages){
+function serviceEvents ($messages,$page){
include dirname(__FILE__,2).'/settings/settings.php';
@@ -896,16 +896,16 @@ function serviceEvents ($messages){
'.$service_date.' |
'.$service_renewal_date.' |
'.$service_status.' |
- '.$general_view.' |
+ '.$general_view.' |
PDF |
';
}
}
//CHECK IF OUTPUT IS MORE THAN X (config setting)
- if (count($messages) == $page_rows_equipment_servicereporst){
+ if (count($messages) == $page_rows_equipment_servicereporst && $page == 'equipment'){
$view_data .= '
- | '.$general_actions_more.' |
+ '.$general_actions_more.' |
';
}
diff --git a/equipment.php b/equipment.php
index e56b7fe..be50548 100644
--- a/equipment.php
+++ b/equipment.php
@@ -254,7 +254,7 @@ if (!empty($responses->geolocation) || $responses->geolocation != ''){
//Get all related service events
if (isAllowed('servicereports',$_SESSION['profile'],$_SESSION['permission'],'R') === 1){
-$service_events = serviceEvents($history);
+$service_events = serviceEvents($history,$page);
$view .= '
+ '.$back_btn_orgin.'
';
-$view .= '
-
-';
-
//Get all related service events
if (empty($history)){
$service_events = '
diff --git a/servicereports.php b/servicereports.php
index 8b11cfd..59b287f 100644
--- a/servicereports.php
+++ b/servicereports.php
@@ -9,8 +9,9 @@ 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';
+$_SESSION['prev_origin_servicereport'] = $_SERVER['REQUEST_URI'];
+$prev_page = (isset($_SESSION['prev_origin_equipment'])) ? $_SESSION['prev_origin_equipment'] : $_SESSION['prev_origin'];
+$page = $_SESSION['origin'] = 'servicereports';
//create backbutton to prev_origin
$back_btn_orgin = ($prev_page != '')? ''.$button_back.'':'';
@@ -25,20 +26,20 @@ if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
$pagination_page = isset($_GET['p']) ? $_GET['p'] : 1;
$status = isset($_GET['status']) ? '&status='.$_GET['status'] : '';
$search = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
+$equipmentid = isset($_GET['equipmentid']) ? '&equipmentid='.$_GET['equipmentid'] : '';
// Determine the URL
-$url = 'index.php?page=servicereports'.$status.$search;
+$url = 'index.php?page=servicereports'.$status.$search.$equipmentid;
//GET Details from URL
$GET_VALUES = urlGETdetails($_GET) ?? '';
//CALL TO API FOR History
-$api_url = '/v1/equipments/type=ServiceReport&'.$GET_VALUES.'&history=0';
+$api_url = '/v1/history/type=ServiceReport&'.$GET_VALUES.'';
$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=';
+$api_url = '/v1/history/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;}
@@ -76,7 +77,7 @@ if (empty($history)){
'.$servicereports_no_history.' |
';
} else {
- $service_events = serviceEvents($history);
+ $service_events = serviceEvents($history,$page);
}
$view .= '