equipmentID.'&type=ServiceReport&history=1'; $history = ioServer($api_url,''); //Decode Payload if (!empty($history)){$history = decode_payload($history);}else{$history = null;} //CALL TO API FOR EQUIPMENT DATA $api_url = '/v1/equipment_data/equipmentid='.$responses->equipmentID; $equipment_data = ioServer($api_url,''); //Decode Payload if (!empty($equipment_data )){$equipment_data = decode_payload($equipment_data );}else{$equipment_data = null;} //GET PRODUCTS_SOFTWARE $api_url = '/v1/products_software/productrowid='.$responses->productrowid.'&status=1'; $products_software = ioServer($api_url,''); //Decode Payload if (!empty($products_software)){$products_software = decode_payload($products_software);}else{$products_software = null;} //------------------------------ //Variables //------------------------------ $status_text = 'status'.$responses->status.'_text'; $warrantydate = warrantyStatus($responses->warranty_date); $service_date_due = serviceStatus($responses->service_date); $firmware_status = availableFirmware($responses->sw_version, $responses->sw_version_latest); //Calculate Healthindex based on last test $total_score = assetHealthIndex($_SESSION['profile'],$_SESSION['permission'],$equipment_data,0); //GetPartnerDetails $partner_data = json_decode($responses->accounthierarchy); $salesid = getPartnerName($partner_data->salesid) ?? $not_specified; $soldto = getPartnerName($partner_data->soldto) ?? '-'; $shipto = getPartnerName($partner_data->shipto) ?? '-'; $location = getPartnerName($partner_data->location) ?? '-'; if (isset($partner_data->section)){$section = getPartnerName($partner_data->section) ?? '-';} else {$section = '-';} //Check if productcode is 0 and status if ($responses->productcode == 0 && $responses->status == 0) {$location = $product_location_raw;} if ($responses->productcode == 0 && $responses->status == 1) {$location = $product_location_SFG;} if ($responses->productcode == 0 && $responses->status == 2) {$location = $product_location_FG;} if ($update_allowed === 1){ if (isset($_POST['description'])) { //GET ALL POST DATA $data = json_encode($_POST, JSON_UNESCAPED_UNICODE); //Secure data $payload = generate_payload($data); //API call $responses = ioServer('/v1/history', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=equipment&equipmentID='.$_POST['equipmentid'].'&success_msg=2'); exit; } } } // 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; } } template_header('Asset', 'asset', 'view'); $view = '

'.$view_asset_h2.' - '.$responses->equipmentID.'

'.$button_cancel.' '; //------------------------------------ //CHECK IF USER IS ALSO CREATOR OF RECORD THEN OVERRIDE UPDATE_ALLOWED_EDIT //------------------------------------ $equipment_owner = (($responses->createdby == $_SESSION['username'])? 1 : 0); //------------------------------------ // //------------------------------------ if ($update_allowed_edit === 1 || $equipment_owner === 1){ $view .= 'Edit'; } $view .= '
'; if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .= '
'; $view .= '
'.$view_asset_information.'

'.$equipment_label3.'

'.$$status_text.'

'.$view_asset_data_ranking.'

'.$total_score.'

'.$equipment_label2.'

'.$responses->serialnumber.'

'.$equipment_label10.'

'.$responses->equipmentID.'

'.$product_code.'

'.(($view_product == 1)? ''.$responses->productcode.'':$responses->productcode).'

'.$product_name.'

'.(($view_product == 1)? ''.(${$responses->productname} ?? $responses->productname).'':(${$responses->productname} ?? $responses->productname)).'

'; $picture = glob("./assets/images/products/".$responses->productcode.".{jpg,jpeg,png,gif}", GLOB_BRACE); if (!empty($picture)){ $view .='
'; } $view .='
'; $view .='
'.$view_asset_partners.'

'.$general_salesid.'

'.$salesid.'

'.$general_soldto.'

'.$soldto.'

'.$general_shipto.'

'.$shipto.'

'.$general_location.'

'.$location.'

'.$general_section.'

'.$section.'

'; $view .= '
'; $view .= '
'.$view_asset_details.'
'; //SHOW ONLY SW_UPGRADE WHEN SET if (isset($products_software) && $products_software !=''){ foreach ($products_software as $products_soft){ if ($products_soft->rowID == $responses->sw_version_upgrade){ $view .= ' '; } } } $view .= '
'.$warranty_status.' '.$warrantydate.'
'.$service_status.' '.$service_date_due.'
'.$software_status.' '.$firmware_status.'
'.$equipment_label5.' '.$responses->hw_version.'
'.$equipment_label6.' '.$responses->sw_version.'
'.($equipment_sw_version_upgrade ?? 'sw_version_upgrade').' '.$products_soft->version.'
'; //SHOW LOCATION BASED ON GEOLOCATION if (!empty($responses->geolocation) || $responses->geolocation != ''){ $geolocation = json_decode($responses->geolocation,true); if ($geolocation[1] != ''){ $view .= '
'; } } //Get all related service events if (isAllowed('servicereports',$_SESSION['profile'],$_SESSION['permission'],'R') === 1){ $service_events = serviceEvents($history,$page); $view .= '
'.$view_asset_servicereport.'
'.$service_events.'
'; } //Show equipment_data when available and allowed if (isAllowed('equipment_data',$_SESSION['profile'],$_SESSION['permission'],'R') === 1 && !empty($equipment_data)){ $view .= '
'.($view_asset_data_text ?? '').'
'; foreach ($equipment_data as $data){ $view .= ''; } $view .= '
'.$view_asset_data_rowID.' '.$view_asset_data_historyid.' '.$view_asset_data_ranking.' '.$general_actions.'
'.$data->rowID.' '.(($view_history == 1)? ''.$data->historyid.'':$data->historyid).' '.$data->healthindex.' '.$general_view.'
'; $view .= '
'; } if ($update_allowed === 1){ $view .= '
'.$view_asset_notes.'
'; } $view .= '
'.$tab3.'
'.$general_created.' '.getRelativeTime($responses->created).'
'.$general_updated.' '.getRelativeTime($responses->updated).'
'; //DISPLAY RELATED COMMUNICATION RECORDS $soldto_id = explode("-",$partner_data->soldto) ?? ''; $shipto_id = explode("-",$partner_data->shipto) ?? ''; $partner_users_id = ($shipto_id[0] != '')? $shipto_id[0] : (($soldto_id[0] != '')? $soldto_id[0] : 1); $view_communication = ''; if ($partner_users_id != 1 && ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4)){ $view_communication = ' '.$button_partner_assigned_communication.''; } //DISPLAY RELATED USERS $view_users =''; if ($partner_users_id != 1 && ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4)){ $view_users = ' '.$button_partner_assigned_users.''; } $view .= '
'.$view_asset_actions.'
'.$button_history.' '.$view_communication.' '.$view_users.' '; if ($update_allowed === 1){ $view .=''.$button_firmware.''; } $view .='
'; //OUTPUT echo $view; template_footer() ?>