From a0e1d386ad14523a01f48b741b1eb1fb47f477e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Tue, 13 Jan 2026 14:35:16 +0100 Subject: [PATCH] Finetuning software updates, general UI improvements --- account_manage.php | 2 +- api/v2/post/history.php | 1 - api/v2/post/payment.php | 33 +++- api/v2/post/products_software_licenses.php | 51 +++--- assets/functions.php | 58 +++++-- assets/softwaretool.js | 4 +- cartest_manage.php | 2 +- category.php | 2 +- communication.php | 2 +- contract_manage.php | 2 +- dealer_manage.php | 2 +- discount.php | 2 +- equipment_manage.php | 2 +- equipments_mass_update.php | 2 +- factuur.php | 7 +- history_manage.php | 2 +- language.php | 2 +- licenses.php | 190 ++++++++++++++++++--- media_manage.php | 2 +- order.php | 19 +-- partner.php | 2 +- pricelists_manage.php | 2 +- product_manage.php | 2 +- products_attributes_manage.php | 2 +- products_configurations.php | 2 +- products_software.php | 2 +- products_software_upgrade_paths_manage.php | 2 +- products_software_version_manage.php | 2 +- products_versions.php | 2 +- profile.php | 2 +- profiles.php | 2 +- rma_manage.php | 2 +- settings.php | 2 +- settings/settingsprofiles.php | 4 +- settings/settingsviews.php | 1 + settings/translations/translations_DE.php | 4 +- settings/translations/translations_ES.php | 1 + settings/translations/translations_NL.php | 1 + settings/translations/translations_PL.php | 1 + settings/translations/translations_PT.php | 1 + settings/translations/translations_US.php | 1 + shipping_manage.php | 2 +- softwaretool.php | 2 +- tax.php | 2 +- translation_manage.php | 2 +- user.php | 2 +- 46 files changed, 317 insertions(+), 120 deletions(-) diff --git a/account_manage.php b/account_manage.php index 9af1788..2e822c1 100644 --- a/account_manage.php +++ b/account_manage.php @@ -140,7 +140,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/api/v2/post/history.php b/api/v2/post/history.php index b24d723..5290e69 100644 --- a/api/v2/post/history.php +++ b/api/v2/post/history.php @@ -155,7 +155,6 @@ if (isset($post_content['sn']) && (isset($post_content['payload']) || isset($pos case 'customer': //update from Portal $historytype = 'Customer'; - $equipmentUpdate = 1; break; default: diff --git a/api/v2/post/payment.php b/api/v2/post/payment.php index e9e559e..1e79ad0 100644 --- a/api/v2/post/payment.php +++ b/api/v2/post/payment.php @@ -1,8 +1,5 @@ fetch(PDO::FETCH_ASSOC); $has_upgrade_paths = ($path_count_result['path_count'] > 0); if (!$has_upgrade_paths) { - // No upgrade paths defined = FREE (lines 240-242 in software_update.php) + // No upgrade paths defined = FREE (lines 328-331 in software_update.php) $final_price = '0.00'; + if (debug) { + debuglog("DEBUG: No upgrade paths defined for version_id $version_id - upgrade is FREE"); + } } else { - // Check for valid upgrade path FROM current version + // Check for valid upgrade path FROM current version (same logic as software_update.php lines 335-353) $sql = 'SELECT pup.price, pup.currency FROM products_software_upgrade_paths pup JOIN products_software_versions from_ver ON pup.from_version_id = from_ver.rowID @@ -93,14 +94,28 @@ if (!$has_upgrade_paths) { $stmt->execute([$version_id, $current_sw_version]); $upgrade_path = $stmt->fetch(PDO::FETCH_ASSOC); + if (debug) { + debuglog("DEBUG: Looking for upgrade path TO version_id=$version_id FROM current_sw_version='$current_sw_version'"); + debuglog("DEBUG: Upgrade path result: " . json_encode($upgrade_path)); + } + if ($upgrade_path) { $final_price = $upgrade_path['price'] ?? '0.00'; $final_currency = $upgrade_path['currency'] ?? 'EUR'; + if (debug) { + debuglog("DEBUG: Found upgrade path - price: $final_price $final_currency"); + } } else { // No upgrade path FROM current version - + if (debug) { + debuglog("ERROR: No valid upgrade path from current version '$current_sw_version' to version_id $version_id"); + } http_response_code(400); - echo json_encode(['error' => 'No valid upgrade path from current version'], JSON_UNESCAPED_UNICODE); + echo json_encode([ + 'error' => 'No valid upgrade path from current version', + 'current_version' => $current_sw_version, + 'target_version_id' => $version_id + ], JSON_UNESCAPED_UNICODE); exit; } } diff --git a/api/v2/post/products_software_licenses.php b/api/v2/post/products_software_licenses.php index 1b3a6fe..1282504 100644 --- a/api/v2/post/products_software_licenses.php +++ b/api/v2/post/products_software_licenses.php @@ -22,7 +22,7 @@ $command = ($id == '')? 'insert' : 'update'; //IF rowID = empty then INSERT if (isset($post_content['delete'])){$command = 'delete';} //change command to delete // Check for bulk creation -$is_bulk = isset($post_content['bulk']) && $post_content['bulk'] === true; +$is_bulk = isset($post_content['bulk']) && ($post_content['bulk'] === "true" || $post_content['bulk'] === true); $date = date('Y-m-d H:i:s'); @@ -37,12 +37,24 @@ $input_insert = ''; if ($command == 'insert' && $is_bulk && isAllowed('products_software_licenses',$profile,$permission,'C') === 1){ $version_id = $post_content['version_id'] ?? ''; - $serials = $post_content['serials'] ?? []; + $serials_input = $post_content['serials'] ?? ''; + + // Convert comma-separated string to array and trim whitespace + if (is_string($serials_input)) { + $serials = array_map('trim', explode(',', $serials_input)); + } elseif (is_array($serials_input)) { + $serials = $serials_input; + } else { + $serials = []; + } + $transaction_id = $post_content['transaction_id'] ?? ''; $license_type = $post_content['license_type'] ?? 0; - $status = $post_content['status'] ?? 0; + $status = $post_content['status'] ?? 1; + $starts_at = $post_content['starts_at'] ?? date('Y-m-d H:i:s'); + $expires_at = $post_content['expires_at'] ?? '2099-12-31 23:59:59'; // effectively permanent - if (empty($version_id) || empty($serials) || !is_array($serials)) { + if (empty($version_id) || empty($serials)) { http_response_code(400); echo json_encode(['error' => 'Invalid parameters for bulk creation']); exit; @@ -51,8 +63,8 @@ if ($command == 'insert' && $is_bulk && isAllowed('products_software_licenses',$ $accounthierarchy = json_encode(array("salesid"=>$partner->salesid,"soldto"=>$partner->soldto), JSON_UNESCAPED_UNICODE); // Prepare statement for bulk insert - $sql = 'INSERT INTO products_software_licenses (version_id, license_key, license_type, status, transaction_id, accounthierarchy, created, createdby) - VALUES (?, ?, ?, ?, ?, ?, ?, ?)'; + $sql = 'INSERT INTO products_software_licenses (version_id, license_key, license_type, status, starts_at, expires_at, transaction_id, accounthierarchy, created, createdby) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $stmt = $pdo->prepare($sql); $created_count = 0; @@ -60,13 +72,7 @@ if ($command == 'insert' && $is_bulk && isAllowed('products_software_licenses',$ if (empty($serial)) continue; // Generate UUID for license key - $license_key = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', - mt_rand(0, 0xffff), mt_rand(0, 0xffff), - mt_rand(0, 0xffff), - mt_rand(0, 0x0fff) | 0x4000, - mt_rand(0, 0x3fff) | 0x8000, - mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) - ); + $license_key = generateUniqueLicenseKey(); try { $stmt->execute([ @@ -74,6 +80,8 @@ if ($command == 'insert' && $is_bulk && isAllowed('products_software_licenses',$ $license_key, $license_type, $status, + $starts_at, + $expires_at, $transaction_id, $accounthierarchy, $date, @@ -81,9 +89,9 @@ if ($command == 'insert' && $is_bulk && isAllowed('products_software_licenses',$ ]); // Assign license to equipment if serial number exists - $eq_sql = 'UPDATE equipment SET sw_version_license = ? WHERE serialnumber = ? AND accounthierarchy LIKE ?'; + $eq_sql = 'UPDATE equipment SET sw_version_license = ? WHERE serialnumber = ? '; $eq_stmt = $pdo->prepare($eq_sql); - $eq_stmt->execute([$license_key, $serial, '%'.$partner->soldto.'%']); + $eq_stmt->execute([$license_key, $serial]); $created_count++; } catch (Exception $e) { @@ -104,17 +112,8 @@ if ($command == 'update'){ $post_content['updatedby'] = $username; } elseif ($command == 'insert'){ - // Generate UUID for license key if not provided - if (empty($post_content['license_key'])) { - $post_content['license_key'] = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', - mt_rand(0, 0xffff), mt_rand(0, 0xffff), - mt_rand(0, 0xffff), - mt_rand(0, 0x0fff) | 0x4000, - mt_rand(0, 0x3fff) | 0x8000, - mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) - ); - } - + // Generate UUID for license key + $post_content['license_key'] = generateUniqueLicenseKey(); $post_content['created'] = $date; $post_content['createdby'] = $username; $post_content['accounthierarchy'] = json_encode(array("salesid"=>$partner->salesid,"soldto"=>$partner->soldto), JSON_UNESCAPED_UNICODE); diff --git a/assets/functions.php b/assets/functions.php index 77ec17a..b9ed30c 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -83,7 +83,9 @@ function send_mail($to, $subject, $message, $attachment, $attachment_name){ if( !$mail->send() ){ // render error if it is $tab = array('error' => 'Mailer Error: '.$mail->ErrorInfo ); - debuglog(json_encode($tab)); + if(debug){ + debuglog(json_encode($tab)); + } exit; } else{ @@ -157,7 +159,9 @@ function sendIcsCalendar($appointment, $to, $subject = 'Appointment Confirmation if (!$mail->send()) { $tab = array('error' => 'Mailer Error: ' . $mail->ErrorInfo); - debuglog(json_encode($tab)); + if(debug){ + debuglog(json_encode($tab)); + } return false; } else { return true; @@ -1067,7 +1071,9 @@ function validate_secure_download_token($token, $secret_key = null) { // Check JSON parsing with detailed error info if ($header === null) { $json_error = json_last_error_msg(); - debuglog("JSON decode failed for header. Raw JSON: " . $header_json . " Error: " . $json_error); + if(debug){ + debuglog("JSON decode failed for header. Raw JSON: " . $header_json . " Error: " . $json_error); + } return ['error' => 'INVALID_TOKEN', 'message' => 'Failed to decode token header JSON: ' . $json_error]; } if ($payload === null) { @@ -1227,6 +1233,11 @@ function log_download($params) { function ioServer($api_call, $data){ include dirname(__FILE__,2).'/settings/settings_redirector.php'; + + if(debug){ + $data_log = is_array($data) ? json_encode($data) : $data; + debuglog($date." - ioServer incoming call: api_call=$api_call, data=" . $data_log); + } $token = $_SESSION['userkey'] ?? 'authorization_request'; $bearertoken = createCommunicationToken($token); @@ -1252,7 +1263,11 @@ function ioServer($api_call, $data){ $resp = curl_exec($curl); $http_status = curl_getinfo($curl) ?? '200'; curl_close($curl); - + + if(debug){ + debuglog($date." - ioServer: URL=$url, HTTP Code=$http_status, Response=" . substr($resp, 0, 500) . (strlen($resp) > 500 ? '...' : '')); + } + //Check If errorcode is returned if($http_status['http_code'] == '403' || $http_status['http_code'] == '400') {$resp = generate_payload('NOK');} @@ -1533,6 +1548,8 @@ function getProfile($profile, $permission){ 'software_update' => 'R', 'software_download' => 'R', 'software_available' => 'R', + 'history' => 'U', + 'payment' => 'U', 'marketing_files' => 'CRUD', 'marketing_folders' => 'CRUD', 'marketing_tags' => 'CRUD', @@ -1553,11 +1570,16 @@ function getProfile($profile, $permission){ ]; // Debug log - debuglog("isAllowed called: page=$page, permission=$permission, action=$action"); - + if(debug){ + debuglog("isAllowed called: page=$page, permission=$permission, action=$action"); + } // 1. Check always allowed if (isset($always_allowed[$page]) && str_contains($always_allowed[$page], $action)) { - debuglog("Allowed by always_allowed"); + + if(debug){ + debuglog("Allowed by always_allowed"); + } + return 1; } @@ -1568,11 +1590,15 @@ function getProfile($profile, $permission){ $page_action = str_contains($user_permission,$action) > 0 ? 1 : 0; //CHECK IF USER IS ALLOWED TO DO THE ACTION $page_access = str_contains($profile,$page) > 0 ? 1 : 0; //CHECK USER IS ALLOWED TO ACCESS PAGE - debuglog("user_permission=$user_permission, page_action=$page_action, page_access=$page_access"); + if(debug){ + debuglog("user_permission=$user_permission, page_action=$page_action, page_access=$page_access"); + } // 2. Check user permissions (standard) if ($page_access == 1 && $page_action == 1){ - debuglog("Allowed by user permissions"); + if(debug){ + debuglog("Allowed by user permissions"); + } return 1; } @@ -1580,16 +1606,22 @@ function getProfile($profile, $permission){ if ($page_access == 0) { foreach ($group_permissions as $granting_page => $grants) { if (str_contains($profile, $granting_page)) { - debuglog("Found granting_page: $granting_page"); + if(debug){ + debuglog("Found granting_page: $granting_page"); + } if (isset($grants[$page]) && str_contains($grants[$page], $action)) { - debuglog("Allowed by group permissions"); + if(debug){ + debuglog("Allowed by group permissions"); + } return 1; } } } } - debuglog("Not allowed"); + if(debug){ + debuglog("Not allowed"); + } // Not allowed return 0; } @@ -5209,7 +5241,7 @@ function updateSoftwareVersionStatus($pdo, $serialnumber = null) { SET e.sw_version_latest = 1 WHERE psv.latest = 1 AND psv.status = 1 - AND lower(e.sw_version) = lower(psv.version) + AND LOWER(TRIM(LEADING "0" FROM e.sw_version)) = lower(psv.version) AND (lower(psv.hw_version) = lower(e.hw_version) OR lower(psv.hw_version) IS NULL OR lower(psv.hw_version) = "") AND e.sw_version_latest = 0' . $sn_clause; diff --git a/assets/softwaretool.js b/assets/softwaretool.js index be93872..280feaf 100644 --- a/assets/softwaretool.js +++ b/assets/softwaretool.js @@ -1034,8 +1034,8 @@ function showPaymentModal(option) { diff --git a/cartest_manage.php b/cartest_manage.php index ed7a1e7..e410d5a 100644 --- a/cartest_manage.php +++ b/cartest_manage.php @@ -181,7 +181,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/category.php b/category.php index c0544b0..63396e5 100644 --- a/category.php +++ b/category.php @@ -104,7 +104,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/communication.php b/communication.php index 9fb97e3..5c3334e 100644 --- a/communication.php +++ b/communication.php @@ -106,7 +106,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/contract_manage.php b/contract_manage.php index f2a6042..032dfae 100644 --- a/contract_manage.php +++ b/contract_manage.php @@ -121,7 +121,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/dealer_manage.php b/dealer_manage.php index 395e7f2..23798f8 100644 --- a/dealer_manage.php +++ b/dealer_manage.php @@ -148,7 +148,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/discount.php b/discount.php index 6945376..67b87ba 100644 --- a/discount.php +++ b/discount.php @@ -120,7 +120,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/equipment_manage.php b/equipment_manage.php index f6edc7f..3c179a8 100644 --- a/equipment_manage.php +++ b/equipment_manage.php @@ -152,7 +152,7 @@ if ($delete_allowed === 1 || $equipment_owner === 1){ $view .= ''; } if ($update_allowed === 1 || $equipment_owner === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/equipments_mass_update.php b/equipments_mass_update.php index 13ff1f8..9f37425 100644 --- a/equipments_mass_update.php +++ b/equipments_mass_update.php @@ -171,7 +171,7 @@ $view = ' if ($update_allowed === 1){ $print_btn_class = ($output_excel_display != '') ? 'btn' : 'btn alt'; $view .= ''; - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/factuur.php b/factuur.php index f394609..713af31 100644 --- a/factuur.php +++ b/factuur.php @@ -59,9 +59,9 @@ if (!empty($invoice_data['customer']['language'])) { // Generate invoice HTML //+++++++++++++++++++++++++++++++++++++++++++++++++++++ -var_dump($invoice_data); list($data, $customer_email, $order_id) = generateSoftwareInvoice($invoice_data, $order_number, $invoice_language); + //+++++++++++++++++++++++++++++++++++++++++++++++++++++ // Check for HTML output request //+++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -92,6 +92,7 @@ $dompdf->render(); $file_name = 'Factuur - ' . $order_id; + //+++++++++++++++++++++++++++++++++++++++++++++++++++++ // Handle different actions //+++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -124,7 +125,7 @@ if (isset($_POST['email_invoice_to_admin'])) { $header_redirect = 'Location: index.php?page=order&id=' . $order_id . '&success=invoice_sent_admin'; // Send to bookkeeping if configured - if (defined('invoice_bookkeeping') && invoice_bookkeeping && defined('email_bookkeeping') && email_bookkeeping) { + if (invoice_bookkeeping && email_bookkeeping) { send_mail(email_bookkeeping, $subject, $message, $attachment, $attachment_name); } @@ -133,7 +134,7 @@ if (isset($_POST['email_invoice_to_admin'])) { } // Show invoice in browser -if (isset($_POST['show_invoice'])) { +if (isset($_GET['show_invoice'])) { // Clean output buffer to prevent corrupted PDF if (ob_get_level()) { ob_end_clean(); diff --git a/history_manage.php b/history_manage.php index 2403cae..d169369 100644 --- a/history_manage.php +++ b/history_manage.php @@ -108,7 +108,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/language.php b/language.php index 1837706..ede9d33 100644 --- a/language.php +++ b/language.php @@ -33,7 +33,7 @@ if (isset($_GET['success_msg'])) {

Translations

- +
diff --git a/licenses.php b/licenses.php index e95c97c..30e1860 100644 --- a/licenses.php +++ b/licenses.php @@ -35,6 +35,77 @@ if ($update_allowed === 1 && isset($_POST['submit'])) { } } +// Handle AJAX API requests +if (isset($_GET['action'])) { + $action = $_GET['action']; + + // Suppress errors for API responses to avoid HTML output breaking JSON + error_reporting(0); + ini_set('display_errors', 0); + + try { + // Licenses data + if ($action === 'licenses_data') { + // Filter out 'page', 'action', and cache busting timestamp from GET parameters + $filtered_params = $_GET; + unset($filtered_params['page']); + unset($filtered_params['action']); + unset($filtered_params['_t']); + + $get_values = urlGETdetails($filtered_params) ?? ''; + $api_url = '/v2/products_software_licenses/' . $get_values; + $response = ioServer($api_url, ''); + header('Content-Type: application/json'); + echo $response; + exit; + } + + // Licenses totals + if ($action === 'licenses_totals') { + // Filter out 'page', 'action', and cache busting timestamp from GET parameters + $filtered_params = $_GET; + unset($filtered_params['page']); + unset($filtered_params['action']); + unset($filtered_params['_t']); + + $get_values = urlGETdetails($filtered_params) ?? ''; + $api_url = '/v2/products_software_licenses/' . $get_values . '&totals='; + $response = ioServer($api_url, ''); + header('Content-Type: application/json'); + echo $response; + exit; + } + + // Software versions for dropdown + if ($action === 'software_versions') { + $api_url = '/v2/products_software_versions/list=&status=1'; + $response = ioServer($api_url, ''); + header('Content-Type: application/json'); + echo $response; + exit; + } + + // Handle license status update via AJAX + if ($action === 'update_license' && $_SERVER['REQUEST_METHOD'] === 'POST') { + if ($update_allowed === 1) { + $data = json_encode($_POST, JSON_UNESCAPED_UNICODE); + $response = ioServer('/v2/products_software_licenses', $data); + header('Content-Type: application/json'); + echo json_encode(['success' => ($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'] : ''; @@ -197,7 +268,7 @@ $view .= ' '.$response->license_key.' '.$response->version_name.' - '.$status_text.' + '.$status_text.' '.($response->transaction_id ?? '-').' '.$starts_display.' '.$expires_display.' @@ -269,6 +340,17 @@ $view .= ' +
+
+ + +
+
+ + +
+
+
@@ -312,13 +394,13 @@ $view .= '
- -
+ +
- -
+ +
@@ -334,8 +416,11 @@ $view .= ' if ($update_allowed === 1) { $view .= ' + '; } @@ -358,12 +443,21 @@ let currentLicenseData = null; // Modal functions function openBulkLicenseModal() { + // Set default dates + const today = new Date().toISOString().split(\'T\')[0]; + document.getElementById("bulk_starts_at").value = today; + document.getElementById("bulk_expires_at").value = "2099-12-31"; + document.getElementById("bulkLicenseModal").style.display = "flex"; } function closeBulkLicenseModal() { document.getElementById("bulkLicenseModal").style.display = "none"; document.getElementById("bulkLicenseForm").reset(); + // Reset date fields to defaults + const today = new Date().toISOString().split(\'T\')[0]; + document.getElementById("bulk_starts_at").value = today; + document.getElementById("bulk_expires_at").value = "2099-12-31"; } // License detail modal functions @@ -385,26 +479,25 @@ function openLicenseModal(licenseData) { let statusClass = ""; if (actualStatus == 0) { statusText = "Inactive"; - statusClass = "id0"; + statusClass = "id2"; } else if (actualStatus == 1) { statusText = "Assigned"; - statusClass = "id1"; } else if (actualStatus == 2) { statusText = "Expired"; statusClass = "id2"; } - // Format dates - const startsDisplay = licenseData.starts_at ? new Date(licenseData.starts_at).toLocaleDateString() : "-"; - const expiresDisplay = licenseData.expires_at ? new Date(licenseData.expires_at).toLocaleDateString() : "-"; + // Format dates for input fields (YYYY-MM-DD) + const startsValue = licenseData.starts_at ? licenseData.starts_at.split(\' \')[0] : ""; + const expiresValue = licenseData.expires_at ? licenseData.expires_at.split(\' \')[0] : ""; // Populate modal fields document.getElementById("detail_license_key").textContent = licenseData.license_key || "-"; document.getElementById("detail_version_name").textContent = licenseData.version_name || "-"; document.getElementById("detail_status").innerHTML = \'\' + statusText + \'\'; document.getElementById("detail_transaction_id").textContent = licenseData.transaction_id || "-"; - document.getElementById("detail_starts_at").textContent = startsDisplay; - document.getElementById("detail_expires_at").textContent = expiresDisplay; + document.getElementById("detail_starts_at").value = startsValue; + document.getElementById("detail_expires_at").value = expiresValue; document.getElementById("detail_assigned_serial").textContent = licenseData.assigned_serial || "-"; // Set hidden form field @@ -462,24 +555,26 @@ document.getElementById("bulkLicenseForm").addEventListener("submit", async func version_id: document.getElementById("bulk_version_id").value, serials: serials, transaction_id: document.getElementById("bulk_transaction_id").value, - license_type: 0, - status: 0 + starts_at: document.getElementById("bulk_starts_at").value, + expires_at: document.getElementById("bulk_expires_at").value, + license_type: 1, + status: 1 }; try { - const response = await fetch("api.php/v2/products_software_licenses", { + const response = await fetch("index.php?page=licenses&action=update_license", { method: "POST", headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + sessionStorage.getItem("token") + "Content-Type": "application/x-www-form-urlencoded", }, - body: JSON.stringify(formData) + body: new URLSearchParams(formData) }); - if (response.ok) { + const result = await response.json(); + if (result.success) { window.location.href = "index.php?page=licenses&success_msg=1"; } else { - alert("Error creating licenses. Please try again."); + alert("Error creating licenses: " + (result.error || "Please try again.")); } } catch (error) { console.error("Error:", error); @@ -496,6 +591,48 @@ function toggleFilters() { panel.style.display = "none"; } } + +// Update license dates function +async function updateLicenseDates() { + const rowID = document.getElementById("detail_rowID").value; + const starts_at = document.getElementById("detail_starts_at").value; + const expires_at = document.getElementById("detail_expires_at").value; + + if (!rowID) { + alert("Invalid license ID"); + return; + } + + // Convert date to timestamp format (YYYY-MM-DD HH:MM:SS) + const starts_at_timestamp = starts_at ? starts_at + " 00:00:00" : ""; + const expires_at_timestamp = expires_at ? expires_at + " 23:59:59" : ""; + + const formData = { + rowID: rowID, + starts_at: starts_at_timestamp, + expires_at: expires_at_timestamp + }; + + try { + const response = await fetch("index.php?page=licenses&action=update_license", { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + body: new URLSearchParams(formData) + }); + + const result = await response.json(); + if (result.success) { + window.location.href = "index.php?page=licenses&success_msg=2"; + } else { + alert("Error updating license: " + (result.error || "Please try again.")); + } + } catch (error) { + console.error("Error:", error); + alert("Error updating license. Please try again."); + } +} '; diff --git a/media_manage.php b/media_manage.php index 04945fa..f0f8d81 100644 --- a/media_manage.php +++ b/media_manage.php @@ -116,7 +116,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= '
'; diff --git a/order.php b/order.php index 0944cbe..4b0329f 100644 --- a/order.php +++ b/order.php @@ -77,6 +77,7 @@ $view = '

'.$order['header']['id'].' - '.$order['header']['txn_id'].'

+ '; @@ -198,7 +199,7 @@ if ($order['customer']['email']) {

Contact

-

' . htmlspecialchars($order['customer']['phone'], ENT_QUOTES) . '

+

' . htmlspecialchars($order['customer']['phone'] ?? '-', ENT_QUOTES) . '

'; } else { $view .='

The order is not associated with an account.

'; @@ -223,14 +224,14 @@ $view .='

Address

' . htmlspecialchars($order['customer']['street'], ENT_QUOTES) . '
- ' . htmlspecialchars($order['customer']['city'], ENT_QUOTES) . '
- ' . htmlspecialchars($order['customer']['state'], ENT_QUOTES) . '
- ' . htmlspecialchars($order['customer']['zip'], ENT_QUOTES) . '
- ' . htmlspecialchars($order['customer']['country'], ENT_QUOTES) . '

+ ' . htmlspecialchars($order['customer']['city'] ?? '-', ENT_QUOTES) . '
+ ' . htmlspecialchars($order['customer']['state'] ?? '-', ENT_QUOTES) . '
+ ' . htmlspecialchars($order['customer']['zip'] ?? '-', ENT_QUOTES) . '
+ ' . htmlspecialchars($order['customer']['country'] ?? '-', ENT_QUOTES) . '

Contact

-

' . htmlspecialchars($order['customer']['phone'], ENT_QUOTES) . '

+

' . htmlspecialchars($order['customer']['phone'] ?? '-', ENT_QUOTES) . '

'; @@ -354,12 +355,6 @@ $view .='
-
-
- - -
-
diff --git a/partner.php b/partner.php index 13f82ea..f393541 100644 --- a/partner.php +++ b/partner.php @@ -113,7 +113,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/pricelists_manage.php b/pricelists_manage.php index ce6c2d4..6923ea4 100644 --- a/pricelists_manage.php +++ b/pricelists_manage.php @@ -172,7 +172,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/product_manage.php b/product_manage.php index b6a5dd6..5877f10 100644 --- a/product_manage.php +++ b/product_manage.php @@ -152,7 +152,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/products_attributes_manage.php b/products_attributes_manage.php index a73de78..bc80286 100644 --- a/products_attributes_manage.php +++ b/products_attributes_manage.php @@ -169,7 +169,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/products_configurations.php b/products_configurations.php index f00c524..00ed4a1 100644 --- a/products_configurations.php +++ b/products_configurations.php @@ -134,7 +134,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/products_software.php b/products_software.php index 6f396ea..bdac74e 100644 --- a/products_software.php +++ b/products_software.php @@ -181,7 +181,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/products_software_upgrade_paths_manage.php b/products_software_upgrade_paths_manage.php index 487f54d..c37f2a6 100644 --- a/products_software_upgrade_paths_manage.php +++ b/products_software_upgrade_paths_manage.php @@ -177,7 +177,7 @@ if ($delete_allowed === 1 && isset($_GET['path_id']) && $_GET['path_id'] != ''){ $view .= ''; } if (($update_allowed === 1 && isset($_GET['path_id'])) || ($create_allowed === 1 && !isset($_GET['path_id']))){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/products_software_version_manage.php b/products_software_version_manage.php index 1aeb700..f3cbbcd 100644 --- a/products_software_version_manage.php +++ b/products_software_version_manage.php @@ -137,7 +137,7 @@ if ($delete_allowed === 1 && isset($_GET['id'])){ $view .= ''; } if (($update_allowed === 1 && isset($_GET['id'])) || ($create_allowed === 1 && !isset($_GET['id']))){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/products_versions.php b/products_versions.php index d9cd839..7e3dedd 100644 --- a/products_versions.php +++ b/products_versions.php @@ -103,7 +103,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/profile.php b/profile.php index f94e321..ff0df19 100644 --- a/profile.php +++ b/profile.php @@ -86,7 +86,7 @@ $view =' '; if ($update_allowed === 1 && $_SESSION['permission'] != 0){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/profiles.php b/profiles.php index 1d3e377..0a6879d 100644 --- a/profiles.php +++ b/profiles.php @@ -281,7 +281,7 @@ $view .= '

Profiles

- +
'; if (isset($success_msg)){ diff --git a/rma_manage.php b/rma_manage.php index 9c8fee5..fd7edb2 100644 --- a/rma_manage.php +++ b/rma_manage.php @@ -405,5 +405,5 @@ $view .= ' //OUTPUT echo $view; -template_footer(); +echo template_footer(); ?> \ No newline at end of file diff --git a/settings.php b/settings.php index 9dd34f7..5e3bd34 100644 --- a/settings.php +++ b/settings.php @@ -125,7 +125,7 @@ $view .= '

Settings

- +
'; diff --git a/settings/settingsprofiles.php b/settings/settingsprofiles.php index 283f91d..45336b7 100644 --- a/settings/settingsprofiles.php +++ b/settings/settingsprofiles.php @@ -4,9 +4,9 @@ define('standard_profile','dashboard,profile,application,firmwaretool,histories, /*Superuser*/ define('superuser_profile','admin,dashboard,profile,application,assets,firmwaretool,histories,history,history_manage,marketing,partner,partners,servicereport,servicereports,equipment,equipment_manage,equipment_manage_edit,equipments,equipments_mass_update,product,product_manage,products,products_software,products_versions,user,user_manage,users'); /*Admin*/ -define('admin_profile','account,accounts,admin,dashboard,profile,application,assets,buildtool,buildtool,cartest,cartest_manage,cartests,changelog,communication,communication_send,communications,firmwaretool,histories,history,history_manage,marketing,partner,partners,sales,servicereport,servicereports,contract,contract_manage,contracts,equipment,equipment_data,equipment_healthindex,equipment_manage,equipment_manage_edit,equipments,equipments_mass_update,product,product_manage,products,products_software,products_versions,report_build,report_contracts_billing,report_healthindex,reporting,rma,rma_history,rma_history_manage,rma_manage,rmas,user,user_manage,users'); +define('admin_profile','account,accounts,admin,dashboard,profile,application,assets,buildtool,buildtool,cartest,cartest_manage,cartests,changelog,communication,communication_send,communications,firmwaretool,histories,history,history_manage,marketing,partner,partners,sales,servicereport,servicereports,software_available,software_download,software_update,softwaretool,contract,contract_manage,contracts,equipment,equipment_data,equipment_healthindex,equipment_manage,equipment_manage_edit,equipments,equipments_mass_update,product,product_manage,products,products_software,products_software_assignment,products_software_assignments,products_versions,report_build,report_contracts_billing,report_healthindex,reporting,rma,rma_history,rma_history_manage,rma_manage,rmas,user,user_manage,users'); /*AdminPlus*/ -define('adminplus_profile','account,account_manage,accounts,admin,config,dashboard,profile,settings,api,application,appointment,assets,billing,buildtool,buildtool,cartest,cartest_manage,cartests,catalog,categories,category,changelog,checkout,com_log,communication,communication_send,communications,cronjob,debug,dev,discount,discounts,factuur,firmwaretool,functions,generate_download_token,histories,history,history_manage,identity,identity_dealers,initialize,invoice,language,licenses,logfile,mailer,maintenance,marketing,marketing_delete,marketing_files,marketing_folders,marketing_migrate,marketing_tags,marketing_upload,media,media_manage,media_scanner,media_upload,order,orders,partner,partners,payment,placeorder,pricelists,pricelists_items,pricelists_manage,profiles,register,render_service_report,reset,sales,security,service,servicereport,servicereports,shipping,shipping_manage,shopping_cart,software_available,software_download,software_update,softwaretool,tax,taxes,test,transactions,transactions_items,translation_manage,translations,translations_details,unscribe,upgrades,uploader,vin,webhook_mollie,webhook_paypal,contract,contract_manage,contracts,dealer,dealer_manage,dealers,dealers_media,equipment,equipment_data,equipment_healthindex,equipment_history,equipment_manage,equipment_manage_edit,equipments,equipments_mass_update,product,product_manage,products,products_attributes,products_attributes_items,products_attributes_manage,products_categories,products_configurations,products_media,products_software,products_software_assignment,products_software_assignments,products_software_assignments,products_software_licenses,products_software_upgrade_paths,products_software_upgrade_paths_manage,products_software_version,products_software_version_access_rules_manage,products_software_version_manage,products_software_versions,products_versions,report_build,report_contracts_billing,report_healthindex,report_usage,reporting,rma,rma_history,rma_history_manage,rma_manage,rmas,user,user_credentials,user_manage,users'); +define('adminplus_profile','account,account_manage,accounts,admin,config,dashboard,profile,settings,api,application,appointment,assets,billing,buildtool,buildtool,cartest,cartest_manage,cartests,catalog,categories,category,changelog,checkout,com_log,communication,communication_send,communications,cronjob,debug,dev,discount,discounts,factuur,firmwaretool,functions,generate_download_token,histories,history,history_manage,identity,identity_dealers,initialize,invoice,language,licenses,logfile,mailer,maintenance,marketing,marketing_delete,marketing_files,marketing_folders,marketing_migrate,marketing_tags,marketing_update,marketing_upload,media,media_manage,media_scanner,media_upload,order,orders,partner,partners,payment,placeorder,pricelists,pricelists_items,pricelists_manage,profiles,register,render_service_report,reset,sales,security,service,servicereport,servicereports,shipping,shipping_manage,shopping_cart,software_available,software_download,software_update,softwaretool,tax,taxes,test,transactions,transactions_items,translation_manage,translations,translations_details,unscribe,upgrades,uploader,vin,webhook_mollie,webhook_paypal,contract,contract_manage,contracts,dealer,dealer_manage,dealers,dealers_media,equipment,equipment_data,equipment_healthindex,equipment_history,equipment_manage,equipment_manage_edit,equipments,equipments_mass_update,product,product_manage,products,products_attributes,products_attributes_items,products_attributes_manage,products_categories,products_configurations,products_media,products_software,products_software_assignment,products_software_assignments,products_software_assignments,products_software_licenses,products_software_upgrade_paths,products_software_upgrade_paths_manage,products_software_version,products_software_version_access_rules_manage,products_software_version_manage,products_software_versions,products_versions,report_build,report_contracts_billing,report_healthindex,report_usage,reporting,rma,rma_history,rma_history_manage,rma_manage,rmas,user,user_credentials,user_manage,users'); /*Build*/ define('build','dashboard,profile,application,buildtool,buildtool,firmwaretool,products_software'); /*Commerce*/ diff --git a/settings/settingsviews.php b/settings/settingsviews.php index 9a4956d..6d0d3e4 100644 --- a/settings/settingsviews.php +++ b/settings/settingsviews.php @@ -71,6 +71,7 @@ $all_views = [ "marketing_folders", "marketing_migrate", "marketing_tags", + "marketing_update", "marketing_upload", "media", "media_manage", diff --git a/settings/translations/translations_DE.php b/settings/translations/translations_DE.php index 458b03a..c0be52e 100644 --- a/settings/translations/translations_DE.php +++ b/settings/translations/translations_DE.php @@ -826,4 +826,6 @@ $dealer_type_0 = 'Lokal'; $dealer_type_1 = 'Professionell'; $dealer_type_2 = 'Unternehmens';$user_information_required = 'Benutzerinformationen Erforderlich'; $user_information_description = 'Bitte geben Sie Ihre Daten ein, um mit Software-Updates fortzufahren'; -$general_continue = 'Fortfahren';?> \ No newline at end of file +$general_continue = 'Fortfahren'; +$payment_method_3 = 'PayPal'; +?> \ No newline at end of file diff --git a/settings/translations/translations_ES.php b/settings/translations/translations_ES.php index 799a0ed..07e33c3 100644 --- a/settings/translations/translations_ES.php +++ b/settings/translations/translations_ES.php @@ -833,4 +833,5 @@ $dealer_type_2 = 'Corporativo'; $user_information_required = 'Información del Usuario Requerida'; $user_information_description = 'Por favor proporcione su información para continuar con las actualizaciones de software'; $general_continue = 'Continuar'; +$payment_method_3 = 'PayPal'; ?> \ No newline at end of file diff --git a/settings/translations/translations_NL.php b/settings/translations/translations_NL.php index 50828f6..24123e9 100644 --- a/settings/translations/translations_NL.php +++ b/settings/translations/translations_NL.php @@ -1039,4 +1039,5 @@ $dealer_type_2 = 'Bedrijf'; $user_information_required = 'Gebruikersinformatie Vereist'; $user_information_description = 'Geef uw gegevens op om door te gaan met software-updates'; $general_continue = 'Doorgaan'; +$payment_method_3 = 'PayPal'; ?> \ No newline at end of file diff --git a/settings/translations/translations_PL.php b/settings/translations/translations_PL.php index 645d187..f5399dc 100644 --- a/settings/translations/translations_PL.php +++ b/settings/translations/translations_PL.php @@ -767,4 +767,5 @@ $general_modifier_1 = '+'; $user_information_required = 'Wymagane Informacje o Użytkowniku'; $user_information_description = 'Podaj swoje dane, aby kontynuować aktualizacje oprogramowania'; $general_continue = 'Kontynuuj'; +$payment_method_3 = 'PayPal'; ?> \ No newline at end of file diff --git a/settings/translations/translations_PT.php b/settings/translations/translations_PT.php index cfa1a59..88b48e7 100644 --- a/settings/translations/translations_PT.php +++ b/settings/translations/translations_PT.php @@ -833,4 +833,5 @@ $dealer_type_2 = 'Corporativo'; $user_information_required = 'Informações do Usuário Obrigatórias'; $user_information_description = 'Por favor, forneça suas informações para continuar com as atualizações de software'; $general_continue = 'Continuar'; +$payment_method_3 = 'PayPal'; ?> \ No newline at end of file diff --git a/settings/translations/translations_US.php b/settings/translations/translations_US.php index 90120e4..54cefbc 100644 --- a/settings/translations/translations_US.php +++ b/settings/translations/translations_US.php @@ -1053,4 +1053,5 @@ $dealer_type_2 = 'Corporate'; $user_information_required = 'User Information Required'; $user_information_description = 'Please provide your information to continue with software updates'; $general_continue = 'Continue'; +$payment_method_3 = 'PayPal'; ?> \ No newline at end of file diff --git a/shipping_manage.php b/shipping_manage.php index 0e279f8..f445bfe 100644 --- a/shipping_manage.php +++ b/shipping_manage.php @@ -104,7 +104,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= ''; diff --git a/softwaretool.php b/softwaretool.php index 6169e92..496ae91 100644 --- a/softwaretool.php +++ b/softwaretool.php @@ -188,7 +188,7 @@ $view .= '
diff --git a/tax.php b/tax.php index 1aa1be9..e2061d8 100644 --- a/tax.php +++ b/tax.php @@ -49,7 +49,7 @@ if (isset($_GET['id'])) { - +
diff --git a/translation_manage.php b/translation_manage.php index d780ec4..e9ba952 100644 --- a/translation_manage.php +++ b/translation_manage.php @@ -174,7 +174,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= '
'; diff --git a/user.php b/user.php index 1dd55dd..341235e 100644 --- a/user.php +++ b/user.php @@ -178,7 +178,7 @@ if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ - $view .= ''; + $view .= ''; } $view .= '
';