($response !== 'NOK'), 'response' => $response]); } else { header('Content-Type: application/json'); echo json_encode(['success' => false, 'error' => 'Not allowed']); } exit; } } catch (Exception $e) { header('Content-Type: application/json'); echo json_encode(['error' => 'Server error', 'message' => $e->getMessage()]); exit; } } //GET PARAMETERS $pagination_page = isset($_GET['p']) ? $_GET['p'] : 1; $status = isset($_GET['status']) ? '&status='.$_GET['status'] : ''; $search = isset($_GET['search']) ? '&search='.$_GET['search'] : ''; // Determine the URL $url = 'index.php?page=licenses'.$status.$search; //GET Details from URL $GET_VALUES = urlGETdetails($_GET) ?? ''; //CALL TO API $api_url = '/v2/products_software_licenses/'.$GET_VALUES; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = json_decode($responses);}else{$responses = null;} //Return QueryTotal from API $api_url = '/v2/products_software_licenses/'.$GET_VALUES.'&totals='; $query_total = ioServer($api_url,''); //Decode Payload if (!empty($query_total)){$query_total = json_decode($query_total,);}else{$query_total = null;} // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { $success_msg = 'Licenses created successfully!'; } if ($_GET['success_msg'] == 2) { $success_msg = 'License updated successfully!'; } if ($_GET['success_msg'] == 3) { $success_msg = 'License deleted successfully!'; } } // Get software versions for dropdown $api_url = '/v2/products_software_versions/list=&status=1'; $software_versions = ioServer($api_url,''); if (!empty($software_versions)){$software_versions = json_decode($software_versions);}else{$software_versions = null;} template_header('Licenses', 'licenses','view'); $view = '

Software Licenses ('.$query_total.')

Manage and create software licenses for devices

'; if ($create_allowed === 1){ $view .= ''; } $view .= '
'; if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .= ' '; $view .= '
'; if (empty($responses)){ $view .= ' '; } else { foreach ($responses as $response){ // Check if license is expired based on timestamp $actual_status = $response->status; if (!empty($response->expires_at)) { $expiry_time = strtotime($response->expires_at); $current_time = time(); if ($current_time > $expiry_time) { // License is expired - override status $actual_status = 2; } } // Status display based on actual status $status_text = ''; if ($actual_status == 0) { $status_text = 'Inactive'; } elseif ($actual_status == 1) { $status_text = 'Assigned'; } elseif ($actual_status == 2) { $status_text = 'Expired'; } // Format dates $starts_display = '-'; if (!empty($response->starts_at)) { $starts_display = date('Y-m-d', strtotime($response->starts_at)); } $expires_display = '-'; if (!empty($response->expires_at)) { $expires_display = date('Y-m-d', strtotime($response->expires_at)); } $view .= ' '; } } $view .= '
License Key Software Version Status Transaction ID Starts At Expires Assigned To (Serial)
No licenses found
'.$response->license_key.' '.$response->version_name.' '.$status_text.' '.($response->transaction_id ?? '-').' '.$starts_display.' '.$expires_display.' '.($response->assigned_serial ?? '-').'
'; $view.=''; // Bulk License Modal $view .= ' '; // License Details Modal $view .= ' '; //OUTPUT echo $view; // Add JavaScript for modals and API calls echo ' '; template_footer(); ?>