From ebecc808ef1a617262ee6eb256f1bd144688992f 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 11:51:37 +0200 Subject: [PATCH] CIM79 - Filter on productname in asset view --- api/v1/get/equipments.php | 8 +++++-- equipments.php | 27 ++++++++++++++++++++--- settings/translations/translations_NL.php | 2 ++ settings/translations/translations_US.php | 2 ++ style/admin.css | 12 ++++++++++ 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/api/v1/get/equipments.php b/api/v1/get/equipments.php index 842ba02..24d3f66 100644 --- a/api/v1/get/equipments.php +++ b/api/v1/get/equipments.php @@ -51,7 +51,7 @@ if(isset($get_content) && $get_content!=''){ $v = explode("=", $y); //INCLUDE VARIABLES IN ARRAY $criterias[$v[0]] = $v[1]; - if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='success_msg' || $v[0] =='download' || $v[0] =='sort'){ + if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='products' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='success_msg' || $v[0] =='download' || $v[0] =='sort'){ //do nothing } elseif ($v[0] == 'equipmentid') { @@ -114,6 +114,10 @@ $sql = 'SELECT e.rowID as equipmentID, e.*, p.productcode, p.productname from eq elseif (isset($criterias['totals']) && $criterias['totals'] =='' && !isset($criterias['type'])){ //Request for total rows $sql = 'SELECT count(*) as count from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.''; +} +elseif (isset($criterias['products']) && $criterias['products'] ==''){ + //Request for all products in equipment view + $sql = 'SELECT distinct(p.productcode), p.productname from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.' ORDER BY p.productcode'; } elseif (isset($criterias['totals']) && $criterias['totals'] =='' && isset($criterias['type'])){ //Request for total rows for history reports @@ -239,7 +243,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['products']) && $criterias['products'] =='') || (isset($criterias['download']) && $criterias['download'] =='')){ //Excute Query $stmt->execute(); //Get results diff --git a/equipments.php b/equipments.php index 0d6e630..4e43b27 100644 --- a/equipments.php +++ b/equipments.php @@ -36,13 +36,13 @@ $software = $_SESSION['firmware'] = isset($_GET['firmware']) ? '&firmware='.$_GE $servicedate = $_SESSION['servicedate'] = isset($_GET['servicedate']) ? '&servicedate='.$_GET['servicedate'] : ''; $warrantydate = $_SESSION['warrantydate'] = isset($_GET['warrantydate']) ? '&warrantydate='.$_GET['warrantydate'] : ''; $partnerid = $_SESSION['partnerid'] = isset($_GET['partnerid']) ? '&partnerid='.$_GET['partnerid'] : ''; - +$productselected = $_SESSION['productcode'] = isset($_GET['productcode']) ? '&productcode='.$_GET['productcode'] : ''; //GET PARAMETERS FOR FILTERS $filter = urlGETdetailsFilter($_GET) ?? ''; // Determine the URL -$url = 'index.php?page=equipments'.$status.$search.$software.$servicedate.$warrantydate.$partnerid.$sort; +$url = 'index.php?page=equipments'.$status.$search.$software.$servicedate.$warrantydate.$partnerid.$sort.$productselected; //GET Details from URL $GET_VALUES = urlGETdetails($_GET) ?? ''; //CALL TO API @@ -57,6 +57,25 @@ $query_total = ioServer($api_url,''); //Decode Payload if (!empty($query_total)){$query_total = decode_payload($query_total);}else{$query_total = null;} +//Get Products related to assets +$api_url = '/v1/equipments/'.$GET_VALUES.'&products='; +$query_products = ioServer($api_url,''); +//Decode Payload +if (!empty($query_products)){$query_products = decode_payload($query_products);}else{$query_products = null;} + +//BUILD LIST OF PRODUCTS +$product_list = ''; + +if ($query_products != null){ + $product_list = ' + '; +} + // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { @@ -110,7 +129,7 @@ $view .= '
'.$general_filters.'
- @@ -119,7 +138,9 @@ $view .= ' + '.$product_list.' + '.$general_filters_clear.'
diff --git a/settings/translations/translations_NL.php b/settings/translations/translations_NL.php index 030c24b..6d5fffa 100644 --- a/settings/translations/translations_NL.php +++ b/settings/translations/translations_NL.php @@ -41,6 +41,8 @@ $general_updated = 'Update'; $general_updatedby = 'Update door'; $general_filters = 'Filters'; +$general_filters_clear = 'opheffen'; + $general_sort = 'Sorteren'; $general_page = 'Pagina '; $general_page_of = ' van '; diff --git a/settings/translations/translations_US.php b/settings/translations/translations_US.php index 95dcbb3..11f6b3d 100644 --- a/settings/translations/translations_US.php +++ b/settings/translations/translations_US.php @@ -41,6 +41,8 @@ $general_updated = 'Updated'; $general_updatedby = 'Updatedby'; $general_filters = 'Filters'; +$general_filters_clear = 'clear'; + $general_sort = 'Sort'; $general_page = 'Page '; $general_page_of = ' of '; diff --git a/style/admin.css b/style/admin.css index b189286..9c270d6 100644 --- a/style/admin.css +++ b/style/admin.css @@ -2670,4 +2670,16 @@ h4.label { #support_btn img:hover{ transform: scale(1.5); +} + +.cancel_link { + white-space: nowrap; + text-align: center; + background: #b44a4a; + border: 0; + padding: 5px 0; + font-size: 9px; + margin-top: 5px; + cursor: pointer; + border-radius: 4px; } \ No newline at end of file