←':''; //Check if allowed if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){ header('location: index.php'); exit; } //GET PARAMETERS && STORE in SESSION for FURTHER USE/NAVIGATION $pagination_page = $_SESSION['p'] = isset($_GET['p']) ? $_GET['p'] : 1; //PAGE Security $page_manage = 'product_manage'; $update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U'); $update_allowed_edit = 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'); $media_update = isAllowed('products_media' ,$_SESSION['profile'],$_SESSION['permission'],'U'); $software_update = isAllowed('products_software_assignment' ,$_SESSION['profile'],$_SESSION['permission'],'U'); //GET Details from URL $GET_VALUES = urlGETdetails($_GET) ?? ''; //CALL TO API FOR General information $api_url = '/v2/products/'.$GET_VALUES; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = json_decode($responses);}else{$responses = null;} $responses = $responses[0]; //CALL TO API FOR Product_versions $api_url = '/v2/products_versions/productrowid='.$_GET['rowID']; $product_versions = ioServer($api_url,''); //Decode Payload if (!empty($product_versions)){$product_versions = json_decode($product_versions);}else{$product_versions = null;} //CALL TO API FOR Product_software $api_url = '/v1/products_software/productrowid='.$_GET['rowID']; $product_software = ioServer($api_url,''); //Decode Payload if (!empty($product_software)){$product_software = decode_payload($product_software);}else{$product_software = null;} //CALL TO API FOR Product_configuration $api_url = '/v2/products_configurations/version_status=1&productrowid='.$_GET['rowID']; $products_configurations = ioServer($api_url,''); //Decode Payload if (!empty($products_configurations)){$products_configurations = json_decode($products_configurations,true);}else{$products_configurations = null;} //GET RELATED CATEGORIES $api_url = '/v2/products_categories/product_id='.$_GET['rowID']; $product['categories'] = ioServer($api_url,''); //Decode Payload if (!empty($product['categories'] )){$product['categories'] = json_decode($product['categories'] ,true);}else{$product['categories'] = null;} //GET RELATED MEDIA $api_url = '/v2/products_media/product_id='.$_GET['rowID']; $products_media = ioServer($api_url,''); //Decode Payload if (!empty($products_media)){$products_media = json_decode($products_media ,true);}else{$products_media = null;} //GET ASSIGNED SOFTWARE VERSIONS $api_url = '/v2/products_software_assignment/product_id='.$_GET['rowID']; $products_software_assignment = ioServer($api_url,''); //Decode Payload if (!empty($products_software_assignment)){$products_software_assignment = json_decode($products_software_assignment,true);}else{$products_software_assignment = null;} if ($media_update == 1){ //GET ALL MEDIA $api_url = '/v2/media/list=product_image'; $media_responses_all = ioServer($api_url,''); //Decode Payload if (!empty($media_responses_all)){$media_responses_all = json_decode($media_responses_all,true);}else{$media_responses_all = null;} } if ($media_update == 1 && (isset($_POST['media']) || isset($_POST['delete']))){ //CHECK IF MEDIA IS AN ARRAY if (isset($_POST['media']) && is_array($_POST['media'])){ foreach($_POST['media'] as $p_media){ //GET ALL POST DATA $payload = json_encode(array("product_id" => $_POST['product_id'], "media_id" => $p_media), JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/products_media', $payload); } if ($responses === 'NOK'){ } else { header('Location: index.php?page=product&success_msg=2&rowID='.$_GET['rowID'].''); exit; } } if (isset($_POST['delete'])){ //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/products_media', $payload); // Redirect and delete product if ($responses === 'NOK'){ } else { header('Location: index.php?page=product&success_msg=2&rowID='.$_GET['rowID'].''); exit; } } } //------------------------------ // Variables //------------------------------ $status_text = 'prod_status_'.$responses->status ?? ''; $product_category_text = 'product_category'.$responses->product_category ?? ''; $parttype_text = 'part_type'.$responses->parttype ?? ''; // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { $success_msg = $message_pr_1; } if ($_GET['success_msg'] == 2) { $success_msg = $message_pr_2; } if ($_GET['success_msg'] == 3) { $success_msg = $message_pr_3; } } template_header('Product', 'product', 'view'); $view = '

'.$responses->productcode.' - '.(${$responses->productname} ?? $responses->productname).'

'; //------------------------------------ // //------------------------------------ if ($update_allowed_edit === 1){ $view .= '✏️'; } $view .= '
'; if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .= '
'; $view .= '
'.($product_data ?? '').'

'.$product_status.'

'.$$status_text.'

'.$product_category.'

'.$$product_category_text.'

'.$product_parttype.'

'.$$parttype_text.'

'.$product_code.'

'.$responses->productcode.'

'.$product_name.'

'.(${$responses->productname} ?? $responses->productname).'

'.($product_slug ?? 'Product_slug').'

'.(${$responses->url_slug} ?? $responses->url_slug).'

'.($product_quantity ?? 'Quantity').'

'.(${$responses->quantity} ?? $responses->quantity).'

'.($product_categories_text ?? 'Categories').'

'; foreach ($product['categories'] as $cat){ $view .= ' ×'.$cat['name'].' '; } $view .= '

'; $view .='
'; $view .='
'; if (!empty($responses->full_path)){ $view .='
'; } $view .='
'; $view .= '
'; $view .= '
'.$product_description.'
'.(${$responses->productdescription} ?? $responses->productdescription).'
'; $view .= '
'.($product_version ?? '').' +
'; if (!empty($product_versions)){ $view .= '
'; foreach ($product_versions as $version){ $view .= ''; } $view .= '
'.$product_version_number.' '.$product_status.' '.$product_version_version.' '.($product_version_config ?? 'Config').'
'.$version->rowID.' '.(($version->status == 1)? ''.$prod_status_1:''.$prod_status_0).' '.$version->version.' '.(!empty($version->config) ? ($general_yes ?? 'Y') : ($general_no ?? 'N')).'
'; } $view .= '
'; if ($responses->configurable == 1){ $view .= '
'.($product_configuration ?? 'Product configuration').' +
'; if (!empty($products_configurations)){ $view .= '
'; foreach ($products_configurations as $product_config){ $view .= ''; } $view .= '
'.($product_configuration_version ?? 'Config-version').' '.($product_configuration_assignment ?? 'Code').' '.($product_configuration_assignment ?? 'Name').'
'.$product_config['version'].' '.$product_config['assignment'].' '.(${$product_config['assignment_name']} ?? $product_config['assignment_name']).'
'; } $view .= '
'; } $view .= '

'.($products_software_assignment_header ?? 'Software').' Manage

'; if(!empty($products_software_assignment)){ foreach ($products_software_assignment as $assignment){ // Get software version details $api_url = '/v2/products_software_versions/rowID=' . $assignment['software_version_id']; $version_details = ioServer($api_url, ''); $version = json_decode($version_details); if (!empty($version)) { $version = $version[0]; $view .= '
' . $version->name . '
Version: ' . $version->version . '
HW: ' . $version->hw_version . '
'; } } } $view .='
'; $view .= '
'.$tab4.'
'.($product_configurable ?? 'Configurable').' '.(($responses->configurable == 1)? $enabled : $disabled).'
'.$product_serialized.' '.(($responses->sn == 1)? $enabled : $disabled).'
'.$product_sales.' '.(($responses->salesflag == 1)? $enabled : $disabled).'
'.$product_build.' '.(($responses->build == 1)? $enabled : $disabled).'
'.$view_asset_data_ranking.' '.(($responses->healthindex == 1)? $enabled : $disabled).'
'; $view .= '

'.($products_media_header ?? 'Product media').'

'; if(!empty($products_media)){ foreach ($products_media as $prod_media){ $view .= '
'; } } $view .='

'.(isset($image_select) ? ${$image_select} : 'Select Images').'

'; if ($media_update == 1){ foreach ($media_responses_all as $media_response){ $view .= ' '.$media_response['title'].' '; } } $view .= '

'; $view .= '

'.(isset($software_select) ? ${$software_select} : 'Select Software Versions').'

'; if ($software_update == 1){ if (isset($software_versions_all) && is_array($software_versions_all)){ foreach ($software_versions_all as $software_version){ $view .= '
' . $software_version['name'] . '
Version: ' . $software_version['version'] . '
HW: ' . $software_version['hw_version'] . '
Upgrade Paths
    '; // Find upgrade paths if (isset($upgrade_paths_all) && is_array($upgrade_paths_all)){ foreach ($upgrade_paths_all as $path) { if ($path['from_version_id'] == $software_version['rowID'] || $path['to_version_id'] == $software_version['rowID']) { $from_ver = ''; $to_ver = ''; foreach ($software_versions_all as $v) { if ($v['rowID'] == $path['from_version_id']) $from_ver = $v['version']; if ($v['rowID'] == $path['to_version_id']) $to_ver = $v['version']; } $view .= '
  • ' . $from_ver . ' -> ' . $to_ver . ' (Price: ' . $path['price'] . ' ' . $path['currency'] . ')
  • '; } } } $view .= '
'; } } } $view .= '

'; $view .= '
'.$tab3.'
'.$general_created.' '.getRelativeTime($responses->created).'
'.$general_createdby.' '.$responses->createdby.'
'.$general_updated.' '.getRelativeTime($responses->updated).'
'.$general_updatedby.' '.$responses->updatedby.'
'; $view .=''; //OUTPUT echo $view; template_footer() ?>