From 9ffb1e41a91a70f3d722ae6e3eeb3cccd394db79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Tue, 8 Oct 2024 16:00:22 +0200 Subject: [PATCH] CMXX - Healthindex. Added healthindex flag to product to include and exclude products from healthindex --- api/v2/get/equipment_healthindex.php | 55 +++++++++++++++++++++++++++- assets/functions.php | 4 +- product.php | 4 ++ product_manage.php | 8 +++- report_healthindex.php | 19 ++++++++++ settings/settingsprofiles.php | 8 ++-- 6 files changed, 90 insertions(+), 8 deletions(-) diff --git a/api/v2/get/equipment_healthindex.php b/api/v2/get/equipment_healthindex.php index e0601f7..8698c96 100644 --- a/api/v2/get/equipment_healthindex.php +++ b/api/v2/get/equipment_healthindex.php @@ -121,8 +121,61 @@ if (isset($criterias['totals']) && $criterias['totals'] ==''){ $sql = 'SELECT count(*) as count FROM products p JOIN equipment e ON p.rowID = e.productrowid JOIN equipment_data ed1 ON e.rowID = ed1.equipmentid LEFT JOIN equipment_data ed2 ON (ed1.equipmentid = ed2.equipmentid AND ed1.rowID < ed2.rowID) '.$whereclause.' AND ed2.rowID IS NULL'; } else { + + // GET SORT INDICATOR + $sort_indicator = $criterias['sort'] ?? ''; + + /* + 1 accounthierarchy ASC + 2 accounthierarchy DESC + 3 Status ASC + 4 Status DESC + 5 Warranty ASC + 6 Warranty DESC + 7 Service ASC + 8 Service DESC + 9 Healthindex ASC + 10 Healthindex DESC + */ + + switch ($sort_indicator){ + case 1: + $sort = ' e.accounthierarchy ASC '; + break; + case 2: + $sort = ' e.accounthierarchy DESC '; + break; + case 3: + $sort = ' e.status ASC '; + break; + case 4: + $sort = ' e.status DESC '; + break; + case 5: + $sort = ' e.warranty_date ASC '; + break; + case 6: + $sort = ' e.warranty_date DESC '; + break; + case 7: + $sort = ' e.service_date ASC '; + break; + case 8: + $sort = ' e.service_date DESC '; + break; + case 9: + $sort = ' ed1.healthindex DESC '; + break; + case 10: + $sort = ' ed1.healthindex ASC '; + break; + default: + $sort = ' e.accounthierarchy '; + break; + } + //SQL for Paging - $sql ='SELECT p.productcode,p.productname,e.productrowid,e.created,e.status,e.accounthierarchy,e.serialnumber,e.hw_version,e.sw_version,e.service_date,e.warranty_date, e.order_ref,e.geolocation, ed1.* FROM products p JOIN equipment e ON p.rowID = e.productrowid JOIN equipment_data ed1 ON e.rowID = ed1.equipmentid LEFT JOIN equipment_data ed2 ON (ed1.equipmentid = ed2.equipmentid AND ed1.rowID < ed2.rowID) '.$whereclause.' AND ed2.rowID IS NULL ORDER BY e.accounthierarchy LIMIT :page,:num_products'; + $sql ='SELECT p.productcode,p.productname,e.productrowid,e.created,e.status,e.accounthierarchy,e.serialnumber,e.hw_version,e.sw_version,e.service_date,e.warranty_date, e.order_ref,e.geolocation, ed1.* FROM products p JOIN equipment e ON p.rowID = e.productrowid JOIN equipment_data ed1 ON e.rowID = ed1.equipmentid LEFT JOIN equipment_data ed2 ON (ed1.equipmentid = ed2.equipmentid AND ed1.rowID < ed2.rowID) '.$whereclause.' AND ed2.rowID IS NULL ORDER BY '.$sort.' LIMIT :page,:num_products'; } $stmt = $pdo->prepare($sql); diff --git a/assets/functions.php b/assets/functions.php index de36f1c..e13e620 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -2250,7 +2250,7 @@ function traintotalMeasurement(){ $pdo = dbConnect($dbname); //GET DATA - $sql = 'SELECT h.rowID, h.description,h.equipmentid,p.productcode,e.hw_version FROM history h JOIN equipment e ON h.equipmentid = e.rowID JOIN products p ON e.productrowid = p.rowID where type="Maintenance_Test" and description like "%doubletestvalues%"'; + $sql = 'SELECT h.rowID, h.description,h.equipmentid,p.productcode,e.hw_version FROM history h JOIN equipment e ON h.equipmentid = e.rowID JOIN products p ON e.productrowid = p.rowID where p.healthindex = 1 and h.type="Maintenance_Test" and h.description like "%doubletestvalues%"'; $stmt = $pdo->prepare($sql); $stmt->execute(); $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -2465,7 +2465,7 @@ function storeMeasurementProduct($total_results, $token){ //Version level //Check version exist - $sql = 'SELECT p.*, pv.rowID as versionID, pv.productrowid as productID FROM products p JOIN products_versions pv ON p.rowID = pv.productrowid WHERE p.productcode = ? and version = ?;'; + $sql = 'SELECT p.*, pv.rowID as versionID, pv.productrowid as productID FROM products p JOIN products_versions pv ON p.rowID = pv.productrowid WHERE p.healthindex = 1 and p.productcode = ? and version = ?;'; $stmt = $pdo->prepare($sql); $versions = ($versions != 'blank')? $versions : ''; $stmt->execute([$products,$versions]); diff --git a/product.php b/product.php index 40363b4..97573e7 100644 --- a/product.php +++ b/product.php @@ -210,6 +210,10 @@ $view .= '
'.$product_build.' '.(($responses->build == 1)? $enabled : $disabled).' + + '.$view_asset_data_ranking.' + '.(($responses->healthindex == 1)? $enabled : $disabled).' +
diff --git a/product_manage.php b/product_manage.php index 8ea1b2a..0360bfc 100644 --- a/product_manage.php +++ b/product_manage.php @@ -37,7 +37,8 @@ $product = [ 'status' => 1, 'build' => 1, 'partnerhierarchy' => '', - 'sn' =>'' + 'sn' =>'', + 'healthindex' =>'' ]; if (isset($_GET['id'])) { @@ -185,6 +186,11 @@ $view .= '
+ +
'; diff --git a/report_healthindex.php b/report_healthindex.php index b4c9493..2cd5bf1 100644 --- a/report_healthindex.php +++ b/report_healthindex.php @@ -112,6 +112,25 @@ $view .= ' '.$general_filters_clear.' + +
+ '.$general_sort.' +
+ + +
'; diff --git a/settings/settingsprofiles.php b/settings/settingsprofiles.php index 6670270..b01b652 100644 --- a/settings/settingsprofiles.php +++ b/settings/settingsprofiles.php @@ -2,19 +2,19 @@ /*Standard*/ define('standard_profile','dashboard,profile,equipments,equipment,histories,history,firmwaretool,servicereports,servicereport,application'); /*Superuser*/ -define('superuser_profile','dashboard,profile,sales,contracts,contract,contract_manage,assets,equipments,equipment,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,marketing,application'); +define('superuser_profile','dashboard,profile,assets,equipments,equipment,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,marketing,application'); /*Service*/ define('service','dashboard,profile,assets,equipments,equipment,equipment_manage,histories,history,history_manage,firmwaretool,servicereports,servicereport,admin,partners,partner,marketing,application'); /*Admin*/ -define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_healthindex,report_usage,application'); +define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_healthindex,application'); /*AdminPlus*/ define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_healthindex,report_usage,config,settings,logfile,changelog,language,application,maintenance,profiles'); /*Build*/ define('build','buildtool,buildtool,application'); /*Distribution*/ -define('distribution',''); +define('distribution','dashboard,profile,assets,equipments,equipment,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,marketing,application'); /*Firmware*/ define('firmware','firmwaretool,application'); /*Interface*/ -define('interface','equipments,firmwaretool,products_versions,application'); +define('interface','equipments,equipment_manage,firmwaretool,products_versions,application'); ?> \ No newline at end of file