diff --git a/.DS_Store b/.DS_Store index 9d4c452..6c22bef 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 4a636e1..d3aeeb0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ api/v2/.DS_Store api/.DS_Store assets/.DS_Store assets/images/.DS_Store +assets/database/ManualUpdates.sql diff --git a/api.php b/api.php index 3bb45e5..1d00f99 100644 --- a/api.php +++ b/api.php @@ -1,6 +1,7 @@ getMessage() . " in " . $exception->getFile() . " on line " . $exception->getLine()); + }); +} + //------------------------------------------ // Header security - enabled via config //------------------------------------------ diff --git a/api/.DS_Store b/api/.DS_Store index 362cceb..25bea50 100644 Binary files a/api/.DS_Store and b/api/.DS_Store differ diff --git a/api/v0/post/application.php b/api/v0/post/application.php index 6a8a550..323d616 100644 --- a/api/v0/post/application.php +++ b/api/v0/post/application.php @@ -56,7 +56,9 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) { // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ $user = $username; $account = $partnerhierarchy; //string - $current_date = date("Y-m-d"); + $service_date = date("Y-m-d", strtotime("+" . SERVICE_MONTHS . " months")); + $warranty_date = date("Y-m-d", strtotime("+" . WARRANTY_MONTHS . " months")); + $order_send_date = date("Y-m-d"); $input_type = $post_content['type']; $testdetails = json_encode($post_content['testdetails']); $serial = $post_content['sn']; @@ -187,9 +189,9 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) { // Create equipment when not exist +++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ if ($equipmentCreate == 1 && $total_equipment == 0){ - $sql = 'INSERT INTO equipment (productrowid,created,createdby,status,accounthierarchy,serialnumber,service_date,warranty_date) VALUES (?,?,?,?,?,?,?,?)'; + $sql = 'INSERT INTO equipment (productrowid,created,createdby,status,accounthierarchy,serialnumber,service_date,warranty_date,order_send_date) VALUES (?,?,?,?,?,?,?,?,?)'; $stmt = $pdo->prepare($sql); - $stmt->execute([$productrowid,$date,$user,$status0,$account,$serial,$current_date,$current_date]); + $stmt->execute([$productrowid,$date,$user,$status0,$account,$serial,$service_date,$warranty_date,$order_send_date]); $rowID = $pdo->lastInsertId(); } @@ -311,7 +313,7 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) { //Update Equipment record $sql = "UPDATE equipment SET service_date = ? $whereclause"; $stmt = $pdo->prepare($sql); - $stmt->execute([$current_date]); + $stmt->execute([$service_date]); } // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/api/v1/.DS_Store b/api/v1/.DS_Store index ad7d9dd..d200a4c 100644 Binary files a/api/v1/.DS_Store and b/api/v1/.DS_Store differ diff --git a/api/v1/post/application.php b/api/v1/post/application.php index 0c397e1..73730fa 100644 --- a/api/v1/post/application.php +++ b/api/v1/post/application.php @@ -84,20 +84,6 @@ switch ($action) { $communication_check = 0; //Check communication record $message_box = []; $timestamp = date("Y-m-d H:i:s"); - - // Create history description - $history_description = [ - "start_date"=>$timestamp, - "end_date"=>date("Y-m-d", strtotime("+730 days")), - "organization"=>strip_tags(trim($post_content['organization'])), - "phone"=>strip_tags(trim($post_content['phone'])), - "city"=>strip_tags(trim($post_content['city'])), - "country"=>strip_tags(trim($post_content['country'])), - "email_consent"=>strip_tags(trim($post_content['email_consent'])), - "terms_consent"=>strip_tags(trim($post_content['terms_consent'])) - ]; - - $description = json_encode($history_description, JSON_UNESCAPED_UNICODE); // -------------------------------------------- // Check if multiple serialnumbers are provided @@ -108,9 +94,12 @@ switch ($action) { foreach ($serial_numbers as $sn) { // Get equipment ID based on serial number - $rowID = getrowID($dbname, 'rowID', 'equipment', 'serialnumber="' . $sn . '"'); + $sql = 'SELECT rowID, warranty_date, order_send_date from equipment where serialnumber = ?'; + $stmt = $pdo->prepare($sql); + $stmt->execute([$sn]); + $rowID = $stmt->fetch(); - if (!$rowID) { + if (!$rowID['rowID']) { // Serial number not recognized $message_box[] = $sn . ' - ' . $register_message_1; continue; @@ -128,8 +117,45 @@ switch ($action) { continue; } + //define warranty_end_date + $order_send_date = $rowID['order_send_date'] ?? $rowID['warranty_date']; + + // Check if order_send_date is available + if (empty($order_send_date)) { + // No valid date found - skip this serial number + $message_box[] = $sn . ' - ' . $register_message_1; // or create a specific message for missing date + continue; + } + + // Calculate warranty end date based on eligibility window + $current_date = new DateTime(); + $order_date = new DateTime($order_send_date); + $months_diff = $current_date->diff($order_date)->m + ($current_date->diff($order_date)->y * 12); + + if ($months_diff <= WARRANTY_ELIGIBILITY_WINDOW) { + // Within eligibility window - apply extended warranty + $warranty_end_date = (clone $order_date)->modify('+' . WARRANTY_EXTENDED_MONTH . ' months')->format('Y-m-d'); + } else { + // Outside eligibility window - apply standard warranty + $warranty_end_date = (clone $order_date)->modify('+' . WARRANTY_MONTHS . ' months')->format('Y-m-d'); + } + // Not under warranty - process registration $firmware_account_send = 1; + + //Create history description + $history_description = [ + "start_date"=>$timestamp, + "end_date"=> $warranty_end_date, + "organization"=>strip_tags(trim($post_content['organization'])), + "phone"=>strip_tags(trim($post_content['phone'])), + "city"=>strip_tags(trim($post_content['city'])), + "country"=>strip_tags(trim($post_content['country'])), + "email_consent"=>strip_tags(trim($post_content['email_consent'])), + "terms_consent"=>strip_tags(trim($post_content['terms_consent'])) + ]; + + $description = json_encode($history_description, JSON_UNESCAPED_UNICODE); // Create history entry $sql = 'INSERT INTO equipment_history (equipmentid, type, description, created, createdby, updatedby) VALUES (?,?,?,?,?,?)'; @@ -190,11 +216,11 @@ switch ($action) { // Update equipment record $sql = 'UPDATE equipment SET status = ?, warranty_date = ?, accounthierarchy = ?, updatedby = ? WHERE rowID = ?'; $stmt = $pdo->prepare($sql); - $stmt->execute(['4', $warranty_extended, $partnerhierarchy_json, $username, $rowID['rowID']]); + $stmt->execute(['4', $warranty_end_date, $partnerhierarchy_json, $username, $rowID['rowID']]); // Add warranty to changelog $warranty_user = $post_content['email'] ?? 'system'; - changelog($dbname, 'equipment', $rowID['rowID'], 'Warranty', $warranty_extended, $warranty_user); + changelog($dbname, 'equipment', $rowID['rowID'], 'Warranty', $warranty_end_date, $warranty_user); // Serial number recognized $message_box[] = $sn . ' - ' . $register_message_3; diff --git a/api/v2/.DS_Store b/api/v2/.DS_Store index 16d8e39..c28ab40 100644 Binary files a/api/v2/.DS_Store and b/api/v2/.DS_Store differ diff --git a/api/v2/get/software_available.php b/api/v2/get/software_available.php index 8f4e4e6..ca139d1 100644 --- a/api/v2/get/software_available.php +++ b/api/v2/get/software_available.php @@ -294,8 +294,9 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){ FROM products_software_upgrade_paths pup JOIN products_software_versions from_ver ON pup.from_version_id = from_ver.rowID WHERE pup.to_version_id = ? - AND LOWER(TRIM(LEADING "0" FROM from_ver.version)) = ? - AND pup.is_active = 1'; + AND (LOWER(TRIM(LEADING "0" FROM from_ver.version)) = ? + OR pup.from_version_id = 9999999) + AND pup.is_active = 1'; $stmt = $pdo->prepare($sql); $stmt->execute([$version['version_id'], $current_sw_version]); $upgrade_path = $stmt->fetch(PDO::FETCH_ASSOC); diff --git a/api/v2/get/software_update.php b/api/v2/get/software_update.php index d56a26e..18f97e4 100644 --- a/api/v2/get/software_update.php +++ b/api/v2/get/software_update.php @@ -332,26 +332,28 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){ } else { //Part of an upgrade path system //Only show if there's an explicit path FROM current version TO this version + // OR a wildcard path (from_version_id = 9999999) $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 WHERE pup.to_version_id = ? - AND LOWER(TRIM(LEADING "0" FROM from_ver.version)) = ? - AND pup.is_active = 1'; + AND (LOWER(TRIM(LEADING "0" FROM from_ver.version)) = ? + OR pup.from_version_id = 9999999) + AND pup.is_active = 1'; $stmt = $pdo->prepare($sql); $stmt->execute([$version['version_id'], $current_sw_version]); $upgrade_path = $stmt->fetch(PDO::FETCH_ASSOC); if ($upgrade_path) { - //Valid upgrade path found FROM current version + //Valid upgrade path found FROM current version or wildcard $show_version = true; $final_price = $upgrade_path['price'] ?? '0.00'; $final_currency = $upgrade_path['currency'] ?? ''; - $decision_reason = 'Showing - found upgrade path FROM current (' . $current_sw_version . ') with price: ' . $final_price . ' ' . $final_currency; + $decision_reason = 'Showing - found upgrade path FROM current (' . $current_sw_version . ') or wildcard with price: ' . $final_price . ' ' . $final_currency; } else { - $decision_reason = 'Skipped - has upgrade paths but none FROM current version (' . $current_sw_version . ')'; + $decision_reason = 'Skipped - has upgrade paths but none FROM current version (' . $current_sw_version . ') or wildcard'; } - //If no path from current version exists, don't show (show_version stays false) + //If no path from current version or wildcard exists, don't show (show_version stays false) } } } diff --git a/api/v2/post/equipments.php b/api/v2/post/equipments.php index f4d14cd..f7adcc8 100644 --- a/api/v2/post/equipments.php +++ b/api/v2/post/equipments.php @@ -148,9 +148,9 @@ if ($command == 'update'){ //RESET WARRANTY AND SERVICE DATES WHEN STATUS IS CHANGED TO SEND(3) if (isset($post_content['status']) && $post_content['status'] == 3 && $equipment_data['status'] != 3) { - $post_content['service_date'] = $date; - $post_content['warranty_date'] = $date; - + $post_content['service_date'] = date("Y-m-d", strtotime("+" . SERVICE_MONTHS . " months")); + $post_content['warranty_date'] = date("Y-m-d", strtotime("+" . WARRANTY_MONTHS . " months")); + $post_content['order_send_date'] = $date; } //UPDATE CHANGELOG BASED ON STATUS CHANGE if (isset($post_content['status']) && $post_content['status'] != $equipment_data['status']) @@ -188,8 +188,15 @@ elseif ($command == 'insert'){ $post_content['created'] = $date; $post_content['createdby'] = $username; $post_content['accounthierarchy'] = $accounthierarchy; - $post_content['service_date'] = $date; - $post_content['warranty_date'] = $date; + $post_content['service_date'] = date("Y-m-d", strtotime("+" . SERVICE_MONTHS . " months")); + $post_content['warranty_date'] = date("Y-m-d", strtotime("+" . WARRANTY_MONTHS . " months")); + + if (isset($post_content['status']) && $post_content['status'] == 3) + { + $post_content['order_send_date'] = $date; + } + + } else { //do nothing diff --git a/api/v2/post/history.php b/api/v2/post/history.php index 5290e69..0861871 100644 --- a/api/v2/post/history.php +++ b/api/v2/post/history.php @@ -44,12 +44,16 @@ if (isset($post_content['sn']) && (isset($post_content['payload']) || isset($pos $updateObject_visual = 0; //update visual inspection object $sendServiceReport = 0; //send service report via email $transfercartest = 0; //Update cartest table with incoming data + $create_software_license = 0; //Create software license + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ //SET DEFAULT PARAMETERS // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ $user = $username; $account = $partnerhierarchy; //string - $current_date = date("Y-m-d"); + $service_date = date("Y-m-d", strtotime("+" . SERVICE_MONTHS . " months")); + $warranty_date = date("Y-m-d", strtotime("+" . WARRANTY_MONTHS . " months")); + $order_send_date = date("Y-m-d"); $input_type = $post_content['type']; $testdetails = json_encode($post_content['payload']); $serial = $post_content['sn']; @@ -146,6 +150,11 @@ if (isset($post_content['sn']) && (isset($post_content['payload']) || isset($pos $transfercartest = 1; break; + case 12: //customer_consent + $historytype = 'Customer_consent'; + $create_software_license = 1; + break; + case 'firmware': //update from Portal $historytype = $HistoryType_2; $equipmentUpdate = 1; @@ -164,14 +173,14 @@ if (isset($post_content['sn']) && (isset($post_content['payload']) || isset($pos // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Connect to DB // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - + //Get whereclause based on serialnumber $whereclause = checkSerial($serial); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ //CHECK if EQUIPMENT EXISTS // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - $sql = "SELECT count(rowID) as total, rowID FROM equipment $whereclause"; + $sql = "SELECT count(rowID) as total, rowID, hw_version FROM equipment $whereclause"; $stmt = $pdo->prepare($sql); $stmt->execute(); $total = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -182,9 +191,9 @@ if (isset($post_content['sn']) && (isset($post_content['payload']) || isset($pos // Create equipment when not exist +++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ if ($equipmentCreate == 1 && $total_equipment == 0){ - $sql = 'INSERT INTO equipment (productrowid,created,createdby,status,accounthierarchy,serialnumber,service_date,warranty_date) VALUES (?,?,?,?,?,?,?,?)'; + $sql = 'INSERT INTO equipment (productrowid,created,createdby,status,accounthierarchy,serialnumber,service_date,warranty_date,order_send_date) VALUES (?,?,?,?,?,?,?,?,?)'; $stmt = $pdo->prepare($sql); - $stmt->execute([$productrowid,$date,$user,$status0,$account,$serial,$current_date,$current_date]); + $stmt->execute([$productrowid,$date,$user,$status0,$account,$serial,$service_date,$warranty_date,$order_send_date]); $rowID = $pdo->lastInsertId(); } @@ -305,7 +314,7 @@ if (isset($post_content['sn']) && (isset($post_content['payload']) || isset($pos //Update Equipment record $sql = "UPDATE equipment SET service_date = ? $whereclause"; $stmt = $pdo->prepare($sql); - $stmt->execute([$current_date]); + $stmt->execute([$service_date]); } // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -357,6 +366,49 @@ if (isset($post_content['sn']) && (isset($post_content['payload']) || isset($pos if ($transfercartest == 1){ convertCartest(); } + + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // create software license ++++++++++++++++++++++++++ + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + if ($create_software_license == 1){ + // Generate unique license key + $license_key = generateUniqueLicenseKey(); + + $sw_version_consent = strtolower($post_content['testdetails']['logdetails']['FW'] ?? '');// version_id + $eq_version_hw = strtolower($rowID['hw_version'] ?? ''); + + //GET VERSION_ID FROM VERSION TABLE + $sql = 'SELECT rowID FROM products_software_versions WHERE version = ? and hw_version = ?'; + $stmt = $pdo->prepare($sql); + $stmt->execute([$sw_version_consent, $eq_version_hw]); + $version_row = $stmt->fetch(PDO::FETCH_ASSOC); + + //GET VERSION_ID or use WILDCARD + $sw_version_consent = $version_row['rowID'] ?? '9999999'; + + // Create license + $sql = 'INSERT INTO products_software_licenses + (version_id, license_type, license_key, status, starts_at, expires_at, transaction_id, created, createdby) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; + $stmt = $pdo->prepare($sql); + $stmt->execute([ + $sw_version_consent, + 1, // license_type (1 = upgrade) + $license_key, + 1, // status = active + date('Y-m-d H:i:s'), + '2099-12-31 23:59:59', // effectively permanent + 'Customer_consent', + date('Y-m-d H:i:s'), + $user + ]); + + // Update equipment.sw_version_license + $sql = 'UPDATE equipment SET sw_version_license = ? WHERE rowID = ?'; + $stmt = $pdo->prepare($sql); + $stmt->execute([$license_key, $rowID]); + } } else { diff --git a/api/v2/post/payment.php b/api/v2/post/payment.php index 1e79ad0..c022b53 100644 --- a/api/v2/post/payment.php +++ b/api/v2/post/payment.php @@ -25,6 +25,11 @@ $user_data = $post_content['user_data'] ?? []; // Read payment_provider from top level first, then fallback to user_data $payment_provider = $post_content['payment_provider'] ?? $user_data['payment_provider'] ?? 'mollie'; +// Extract tax information from user_data (sent from frontend) +$item_price = $user_data['item_price'] ?? null; // Price without VAT +$tax_amount = $user_data['tax_amount'] ?? 0; // VAT amount +$payment_amount = $user_data['payment_amount'] ?? null; // Total including VAT + //+++++++++++++++++++++++++++++++++++++++++++++++++++++ // STEP 1: Get equipment data from serial_number //+++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -165,8 +170,17 @@ if (debug) { // STEP 7: Create payment based on provider //+++++++++++++++++++++++++++++++++++++++++++++++++++++ try { + // Use payment_amount (with tax) if provided, otherwise use final_price + $amount_to_charge = $payment_amount ? (float)$payment_amount : (float)$final_price; + // Format price (must be string with 2 decimals) - $formatted_price = number_format((float)$final_price, 2, '.', ''); + $formatted_price = number_format($amount_to_charge, 2, '.', ''); + + if (debug) { + debuglog("DEBUG: Item Price (excl. VAT): " . ($item_price ?? $final_price)); + debuglog("DEBUG: Tax Amount: " . $tax_amount); + debuglog("DEBUG: Total Amount (incl. VAT): " . $amount_to_charge); + } //+++++++++++++++++++++++++++++++++++++++++++++++++++++ // STEP 7A: Generate transaction ID BEFORE creating payment @@ -252,7 +266,7 @@ try { throw new Exception("No approval URL received from PayPal"); } - $payment_method_id = 1; // PayPal + $payment_method_id = 3; // PayPal $payment_metadata = 'paypal_order_id'; } else { @@ -291,7 +305,7 @@ try { debuglog("DEBUG: Checkout URL: $checkout_url"); } - $payment_method_id = 0; // Mollie + $payment_method_id = 1; // Mollie $payment_metadata = 'mollie_payment_id'; } @@ -313,13 +327,14 @@ try { // BUILD UP PARTNERHIERARCHY FROM USER $partner_product = json_encode(array("salesid"=>$partner->salesid,"soldto"=>$partner->soldto), JSON_UNESCAPED_UNICODE); - $sql = 'INSERT INTO transactions (txn_id, payment_amount, payment_status, payer_email, first_name, last_name, + $sql = 'INSERT INTO transactions (txn_id, payment_amount, tax_amount, payment_status, payer_email, first_name, last_name, address_street, address_city, address_state, address_zip, address_country, account_id, payment_method, accounthierarchy, created) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $stmt = $pdo->prepare($sql); $stmt->execute([ $txn_id, - $final_price, + $amount_to_charge, // Total amount including tax + $tax_amount, // Tax amount 0, // 0 = pending $user_data['email'] ?? '', $first_name, @@ -348,13 +363,16 @@ try { $payment_metadata => $payment_id // Store payment provider ID ], JSON_UNESCAPED_UNICODE); + // Use item_price (without VAT) if provided, otherwise use final_price + $item_price_to_store = $item_price ? (float)$item_price : (float)$final_price; + $sql = 'INSERT INTO transactions_items (txn_id, item_id, item_price, item_quantity, item_options, created) VALUES (?, ?, ?, ?, ?, ?)'; $stmt = $pdo->prepare($sql); $stmt->execute([ $transaction_id, $version_id, - $final_price, + $item_price_to_store, // Price without VAT 1, $item_options, date('Y-m-d H:i:s') diff --git a/assets/.DS_Store b/assets/.DS_Store index 1ba4cf5..7502f1f 100644 Binary files a/assets/.DS_Store and b/assets/.DS_Store differ diff --git a/assets/functions.php b/assets/functions.php index ed8aff8..f17faaa 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -1264,8 +1264,10 @@ function ioServer($api_call, $data){ $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 ? '...' : '')); + + if (debug) { + $resp_log = $date . " - ioServer: URL=$url, HTTP Code= ". ($http_status['http_code'] ?? 'unknown') . ", Response=" . substr($resp, 0, 500) . (strlen($resp) > 500 ? '...' : ''); + debuglog(json_encode($resp_log)); } //Check If errorcode is returned @@ -1728,33 +1730,38 @@ function getPartnerID($str){ // overview Indicators //------------------------------------------ function overviewIndicators($warranty, $service, $sw_version, $sw_version_latest){ - include dirname(__FILE__,2).'/settings/settings_redirector.php'; - include dirname(__FILE__,2).'/settings/systemfirmware.php'; - $indicator =''; - //In warranty - if (!empty($warranty ) && $warranty > $warrantydate){ - $indicator .= 'W'; - } else { - $indicator .= 'W'; - } - //Out of Service - if (!empty($service) && $service < $servicedate){ - $indicator .= 'S'; - } else { - $indicator .= 'S'; - } + + include dirname(__FILE__,2).'/settings/settings_redirector.php'; + include dirname(__FILE__,2).'/settings/systemfirmware.php'; + + $indicator =''; + $current_date = date('Y-m-d'); + + //In warranty + if (!empty($warranty ) && $warranty >= $current_date){ + $indicator .= 'W'; + } else { + $indicator .= 'W'; + } + //Out of Service + if (!empty($service) && $service >= $current_date){ + $indicator .= 'S'; + } else { + $indicator .= 'S'; + } //Firmware if (isset($sw_version_latest)){ - if($sw_version_latest == 1){ - $indicator .= 'F'; + if($sw_version_latest == 1){ + $indicator .= 'F'; + } + else { + if ($sw_version == ''){ + $indicator .= 'F'; } else { - if ($sw_version == ''){ - $indicator .= 'F'; - } else { - $indicator .= 'F'; - } + $indicator .= 'F'; } + } } return $indicator; @@ -1783,11 +1790,12 @@ function warrantyStatus($input){ } $warranty_date_due ='Unknown'; - - if (!empty($input) && $input < $warrantydate){ - $warranty_date_due = ''.$warranty_outdated_text.''; + $current_date = date('Y-m-d'); + + if (!empty($input) && $input >= $current_date){ + $warranty_date_due = ''.$warranty_recent.' ('.$input.')'; } else { - $warranty_date_due = ''.$warranty_recent.' ('.date('Y-m-d', strtotime($input. ' + 365 days')).')'; + $warranty_date_due = ''.$warranty_outdated_text.''; } return $warranty_date_due; @@ -1814,13 +1822,15 @@ function serviceStatus($input){ else { include dirname(__FILE__,2).'/settings/translations/translations_US.php'; } - + + $current_date = date('Y-m-d'); $service_date_due ='Unknown'; - if (!empty($input) && $input < $servicedate){ - $service_date_due = ''.$service_renewal_text.''; + if (!empty($input) && $input >= $current_date){ + $service_date_due =''.$service_recent.' ('.$input.')'; } else { - $service_date_due =''.$service_recent.' ('.date('Y-m-d', strtotime($input. ' + 365 days')).')'; + $service_date_due = ''.$service_renewal_text.''; + } return $service_date_due; @@ -2976,20 +2986,29 @@ function showlog($object,$objectID){ $stmt->execute([$object,$objectID]); $changes = $stmt->fetchAll(PDO::FETCH_ASSOC); - $view = ''; - foreach($changes as $change){ - - $object_value = $change['object_value']; - - //UPDATE TO HUMANREADABLE STATUS - if ($object == 'equipment' && $change['object_field'] == 'status'){ - $object_text = 'status'.$change['object_value'].'_text'; - $object_value = $$object_text; + $view = '
'.$entry.'
+Version: ${option.version || "N/A"}
-${option.description || ""}
-