CIM79 - Filter on productname in asset view

This commit is contained in:
“VeLiTi”
2024-05-17 11:51:37 +02:00
parent 2036869663
commit ebecc808ef
5 changed files with 46 additions and 5 deletions

View File

@@ -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

View File

@@ -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 = '
<select name="productcode">
<option value="" disabled selected>'.$equipment_label4.'</option>';
foreach ($query_products as $product){
$product_list .= '<option value="'.$product->productcode.'">'.$product->productname.'</option>';
}
$product_list .= '</select>';
}
// Handle success messages
if (isset($_GET['success_msg'])) {
if ($_GET['success_msg'] == 1) {
@@ -110,7 +129,7 @@ $view .= '
<div class="filters">
<a href="#"><i class="fa-solid fa-filter"></i>'.$general_filters.'</a>
<div class="list">
<select name="status">
<select name="status">
<option value="" disabled selected>'.$equipment_label3.'</option>
<option value="0"'.($status==0?' selected':'').'>'.$status0_text.'</option>
<option value="1"'.($status==1?' selected':'').'>'.$status1_text.'</option>
@@ -119,7 +138,9 @@ $view .= '
<option value="4"'.($status==4?' selected':'').'>'.$status4_text.'</option>
<option value="5"'.($status==5?' selected':'').'>'.$status5_text.'</option>
</select>
'.$product_list.'
<button type="submit">'.$button_apply.'</button>
<a class="cancel_link" style="color: #FFFFFF;text-decoration: none;" href="index.php?page=equipments">'.$general_filters_clear.'</a>
</div>
</div>
<div class="sort">

View File

@@ -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 ';

View File

@@ -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 ';

View File

@@ -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;
}