'.$button_back.'':''; //Check if allowed if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){ header('location: index.php'); exit; } //PAGE Security $page_manage = 'equipment_manage'; $update_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'U'); $delete_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'D'); $create_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'C'); //GET PARAMETERS && STORE in SESSION for FURTHER USE/NAVIGATION $pagination_page = $_SESSION['p'] = isset($_GET['p']) ? $_GET['p'] : 1; $status = $_SESSION['status'] = isset($_GET['status']) ? '&status='.$_GET['status'] : ''; $sort = $_SESSION['sort'] = isset($_GET['sort']) ? '&sort='.$_GET['sort'] : ''; $search = $_SESSION['search'] = isset($_GET['search']) ? '&search='.$_GET['search'] : ''; $software = $_SESSION['firmware'] = isset($_GET['firmware']) ? '&firmware='.$_GET['firmware'] : ''; $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'] : ''; $serialnumber_input = $_SESSION['serialnumber'] = isset($_GET['serialnumber']) ? '&serialnumber='.$_GET['serialnumber'] : ''; //GET PARAMETERS FOR FILTERS $filter = urlGETdetailsFilter($_GET) ?? ''; // Determine the URL $url = 'index.php?page=equipments'.$status.$search.$software.$servicedate.$warrantydate.$partnerid.$sort.$productselected.$serialnumber_input; //GET Details from URL $GET_VALUES = urlGETdetails($_GET) ?? ''; //CALL TO API $api_url = '/v1/equipments/'.$GET_VALUES; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;} //Return QueryTotal from API $api_url = '/v1/equipments/'.$GET_VALUES.'&totals='; $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) { $success_msg = $message_eq_1; } if ($_GET['success_msg'] == 2) { $success_msg = $message_eq_2; } if ($_GET['success_msg'] == 3) { $success_msg = $message_eq_3; } } if (isset($_GET['download'])){ downloadToExcel('equipment',$responses); } template_header('Assets', 'assets','view'); $view = '

'.$assets_h2.' ('.$query_total.')

'.$assets_p.'

'.$back_btn_orgin.'
'; if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .= '
'; if ($create_allowed ===1){ $view .= ''.$button_create_asset.''; } $view .= '
'.$filter.'
'.$general_filters.'
'.$product_list.' '.$general_filters_clear.'
'.$general_sort.'
'; //SHOW DOWNLOAD TO EXCELL OPTION ONLY TO ADMIN USERS if ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4){ $view .='
'; } $view .= '
'; $view .= '
'; if (empty($responses)){ $view .= ' '; } foreach ($responses as $response){ //Translate status INT to STR $status_text = 'status'.$response->status.'_text'; //GetPartnerDetails $partner_data = json_decode($response->accounthierarchy); //Default location $location = getPartnerName($partner_data->location) ?? $not_specified; //Check if productcode is 0 and status if ($response->productcode == 0 && $response->status == 0) {$location = $product_location_raw;} if ($response->productcode == 0 && $response->status == 1) {$location = $product_location_SFG;} if ($response->productcode == 0 && $response->status == 2) {$location = $product_location_FG;} //Check for Section if (isset($partner_data->section)){$section = getPartnerName($partner_data->section) ?? $not_specified;} else {$section = $not_specified;} $picture = glob("./assets/images/products/".$response->productcode.".{jpg,jpeg,png,gif}", GLOB_BRACE); $indicators = overviewIndicators($response->warranty_date,$response->service_date,$response->sw_version, $response->sw_version_latest); $view .= ''; $view .= ' '; } $view .= '
'.$equipment_label1.' '.$equipment_label2.' '.$equipment_label3.' '.$equipment_label4.' '.$general_location.' '.$general_section.' '.$view_asset_actions.'
'.$message_no_assets.'
'.$indicators.' '.$response->serialnumber.' '.$$status_text.' '.$response->productcode.'-'.(${$response->productname} ?? $response->productname).''; if (!empty($picture)){ $view .=' '; } $view .= ' '.$location.' '.$section.' '.$general_view .'
'; $view.=''; //OUTPUT echo $view; template_footer(); ?>