From e4cc9f4ef340d442b75cad606adf47b7fb82281a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Thu, 16 May 2024 15:56:20 +0200 Subject: [PATCH] CIM77 - Service reports alleen laatste 5 --- api/v1/get/equipments.php | 31 ++++++++++++++++++++--- assets/functions.php | 12 ++++++--- equipment.php | 2 +- servicereports.php | 12 +++++++-- settings/translations/translations_NL.php | 1 + settings/translations/translations_US.php | 3 +-- 6 files changed, 50 insertions(+), 11 deletions(-) diff --git a/api/v1/get/equipments.php b/api/v1/get/equipments.php index f34efbc..377add0 100644 --- a/api/v1/get/equipments.php +++ b/api/v1/get/equipments.php @@ -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 diff --git a/assets/functions.php b/assets/functions.php index 616b485..b842209 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -900,16 +900,22 @@ function serviceEvents ($messages){ PDF '; } - $view_data .= ''; + + } + //CHECK IF OUTPUT IS MORE THAN X (config setting) + if (count($messages) == $page_rows_equipment_servicereporst){ + $view_data .= ' + '.$general_actions_more.' + '; } - if ($view_data == ''){ $view_data = ' '.$service_report_no_text.' '; } - + + $view_data .= ''; $view_footer = ''; $view = $view_header.$view_data.$view_footer; diff --git a/equipment.php b/equipment.php index 74d9a0e..e56b7fe 100644 --- a/equipment.php +++ b/equipment.php @@ -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 diff --git a/servicereports.php b/servicereports.php index 9e35c3c..8b11cfd 100644 --- a/servicereports.php +++ b/servicereports.php @@ -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 != '')? ''.$button_back.'':''; + //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 = '

'.$servicereports_p.'

+ '.$back_btn_orgin.' '; $view .= ' diff --git a/settings/translations/translations_NL.php b/settings/translations/translations_NL.php index 1cc875e..030c24b 100644 --- a/settings/translations/translations_NL.php +++ b/settings/translations/translations_NL.php @@ -55,6 +55,7 @@ $general_first = '↤'; // <-First; $general_view = 'Bekijk'; $general_actions = 'Acties'; +$general_actions_more = 'Meer resultaten'; $general_profile = 'Profiel'; $general_logout = 'Uitloggen'; diff --git a/settings/translations/translations_US.php b/settings/translations/translations_US.php index b496405..95dcbb3 100644 --- a/settings/translations/translations_US.php +++ b/settings/translations/translations_US.php @@ -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';